diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt index 75edd8da4997e5..a206757d729531 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlEntryChangedEvent ( - val adminNodeID: ULong?, - val adminPasscodeID: UInt?, - val changeType: UInt, - val latestValue: chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct?, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlEntryChangedEvent( + val adminNodeID: ULong?, + val adminPasscodeID: UInt?, + val changeType: UInt, + val latestValue: + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct?, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlEntryChangedEvent {\n") append("\tadminNodeID : $adminNodeID\n") append("\tadminPasscodeID : $adminPasscodeID\n") @@ -46,21 +44,21 @@ class AccessControlClusterAccessControlEntryChangedEvent ( tlvWriter.apply { startStructure(tlvTag) if (adminNodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } if (adminPasscodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } put(ContextSpecificTag(TAG_CHANGE_TYPE), changeType) if (latestValue != null) { - latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) - } else { - putNull(ContextSpecificTag(TAG_LATEST_VALUE)) - } + latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) + } else { + putNull(ContextSpecificTag(TAG_LATEST_VALUE)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -73,32 +71,45 @@ class AccessControlClusterAccessControlEntryChangedEvent ( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlEntryChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlEntryChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUInt(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = if (!tlvReader.isNull()) { - chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = + if (!tlvReader.isNull()) { + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct + .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) + return AccessControlClusterAccessControlEntryChangedEvent( + adminNodeID, + adminPasscodeID, + changeType, + latestValue, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt index 31aad754e04833..8377cc96d5f545 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlExtensionChangedEvent ( - val adminNodeID: ULong?, - val adminPasscodeID: UInt?, - val changeType: UInt, - val latestValue: chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlExtensionChangedEvent( + val adminNodeID: ULong?, + val adminPasscodeID: UInt?, + val changeType: UInt, + val latestValue: + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlExtensionChangedEvent {\n") append("\tadminNodeID : $adminNodeID\n") append("\tadminPasscodeID : $adminPasscodeID\n") @@ -46,21 +44,21 @@ class AccessControlClusterAccessControlExtensionChangedEvent ( tlvWriter.apply { startStructure(tlvTag) if (adminNodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } if (adminPasscodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } put(ContextSpecificTag(TAG_CHANGE_TYPE), changeType) if (latestValue != null) { - latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) - } else { - putNull(ContextSpecificTag(TAG_LATEST_VALUE)) - } + latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) + } else { + putNull(ContextSpecificTag(TAG_LATEST_VALUE)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -73,32 +71,45 @@ class AccessControlClusterAccessControlExtensionChangedEvent ( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlExtensionChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlExtensionChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUInt(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = if (!tlvReader.isNull()) { - chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = + if (!tlvReader.isNull()) { + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct + .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlExtensionChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) + return AccessControlClusterAccessControlExtensionChangedEvent( + adminNodeID, + adminPasscodeID, + changeType, + latestValue, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt index b608b8499d5445..5c1bf98d9c4f79 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt @@ -17,18 +17,14 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccountLoginClusterLoggedOutEvent ( - val node: Optional) { - override fun toString(): String = buildString { +class AccountLoginClusterLoggedOutEvent(val node: Optional) { + override fun toString(): String = buildString { append("AccountLoginClusterLoggedOutEvent {\n") append("\tnode : $node\n") append("}\n") @@ -38,9 +34,9 @@ class AccountLoginClusterLoggedOutEvent ( tlvWriter.apply { startStructure(tlvTag) if (node.isPresent) { - val optnode = node.get() - put(ContextSpecificTag(TAG_NODE), optnode) - } + val optnode = node.get() + put(ContextSpecificTag(TAG_NODE), optnode) + } endStructure() } } @@ -48,14 +44,15 @@ class AccountLoginClusterLoggedOutEvent ( companion object { private const val TAG_NODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccountLoginClusterLoggedOutEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccountLoginClusterLoggedOutEvent { tlvReader.enterStructure(tlvTag) - val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - + val node = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return AccountLoginClusterLoggedOutEvent(node) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt index 59405162837cd8..ea2f1931564f35 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActionsClusterActionFailedEvent ( - val actionID: UInt, - val invokeID: ULong, - val newState: UInt, - val error: UInt) { - override fun toString(): String = buildString { +class ActionsClusterActionFailedEvent( + val actionID: UInt, + val invokeID: ULong, + val newState: UInt, + val error: UInt +) { + override fun toString(): String = buildString { append("ActionsClusterActionFailedEvent {\n") append("\tactionID : $actionID\n") append("\tinvokeID : $invokeID\n") @@ -57,13 +54,13 @@ class ActionsClusterActionFailedEvent ( private const val TAG_NEW_STATE = 2 private const val TAG_ERROR = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterActionFailedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterActionFailedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUInt(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getULong(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) val error = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR)) - + tlvReader.exitContainer() return ActionsClusterActionFailedEvent(actionID, invokeID, newState, error) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt index 868fbace2ac50e..d95c5e9d66480b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt @@ -17,20 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActionsClusterStateChangedEvent ( - val actionID: UInt, - val invokeID: ULong, - val newState: UInt) { - override fun toString(): String = buildString { +class ActionsClusterStateChangedEvent(val actionID: UInt, val invokeID: ULong, val newState: UInt) { + override fun toString(): String = buildString { append("ActionsClusterStateChangedEvent {\n") append("\tactionID : $actionID\n") append("\tinvokeID : $invokeID\n") @@ -53,12 +46,12 @@ class ActionsClusterStateChangedEvent ( private const val TAG_INVOKE_I_D = 1 private const val TAG_NEW_STATE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUInt(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getULong(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) - + tlvReader.exitContainer() return ActionsClusterStateChangedEvent(actionID, invokeID, newState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt index 8ca5a2a0195e9c..6d2c068c849afb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterLeaveEvent ( - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class BasicInformationClusterLeaveEvent(val fabricIndex: UInt) { + override fun toString(): String = buildString { append("BasicInformationClusterLeaveEvent {\n") append("\tfabricIndex : $fabricIndex\n") append("}\n") @@ -45,10 +40,10 @@ class BasicInformationClusterLeaveEvent ( companion object { private const val TAG_FABRIC_INDEX = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterLeaveEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterLeaveEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BasicInformationClusterLeaveEvent(fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt index 4a6bf00b468e48..4e6cb20e13c5e0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterReachableChangedEvent ( - val reachableNewValue: Boolean) { - override fun toString(): String = buildString { +class BasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { + override fun toString(): String = buildString { append("BasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") append("}\n") @@ -45,10 +40,10 @@ class BasicInformationClusterReachableChangedEvent ( companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterReachableChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt index b87f7ebee81d72..5ba3a8d3591e9a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterStartUpEvent ( - val softwareVersion: ULong) { - override fun toString(): String = buildString { +class BasicInformationClusterStartUpEvent(val softwareVersion: ULong) { + override fun toString(): String = buildString { append("BasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("}\n") @@ -45,10 +40,10 @@ class BasicInformationClusterStartUpEvent ( companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterStartUpEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt index 632226d00db082..f133fd21988180 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BooleanStateClusterStateChangeEvent ( - val stateValue: Boolean) { - override fun toString(): String = buildString { +class BooleanStateClusterStateChangeEvent(val stateValue: Boolean) { + override fun toString(): String = buildString { append("BooleanStateClusterStateChangeEvent {\n") append("\tstateValue : $stateValue\n") append("}\n") @@ -45,10 +40,10 @@ class BooleanStateClusterStateChangeEvent ( companion object { private const val TAG_STATE_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateClusterStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BooleanStateClusterStateChangeEvent { tlvReader.enterStructure(tlvTag) val stateValue = tlvReader.getBoolean(ContextSpecificTag(TAG_STATE_VALUE)) - + tlvReader.exitContainer() return BooleanStateClusterStateChangeEvent(stateValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt index 81fa108828d662..4c7e0fd2bb6110 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BooleanStateConfigurationClusterAlarmsStateChangedEvent ( - val alarmsActive: UInt, - val alarmsSuppressed: Optional) { - override fun toString(): String = buildString { +class BooleanStateConfigurationClusterAlarmsStateChangedEvent( + val alarmsActive: UInt, + val alarmsSuppressed: Optional +) { + override fun toString(): String = buildString { append("BooleanStateConfigurationClusterAlarmsStateChangedEvent {\n") append("\talarmsActive : $alarmsActive\n") append("\talarmsSuppressed : $alarmsSuppressed\n") @@ -41,9 +39,9 @@ class BooleanStateConfigurationClusterAlarmsStateChangedEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ALARMS_ACTIVE), alarmsActive) if (alarmsSuppressed.isPresent) { - val optalarmsSuppressed = alarmsSuppressed.get() - put(ContextSpecificTag(TAG_ALARMS_SUPPRESSED), optalarmsSuppressed) - } + val optalarmsSuppressed = alarmsSuppressed.get() + put(ContextSpecificTag(TAG_ALARMS_SUPPRESSED), optalarmsSuppressed) + } endStructure() } } @@ -52,15 +50,19 @@ class BooleanStateConfigurationClusterAlarmsStateChangedEvent ( private const val TAG_ALARMS_ACTIVE = 0 private const val TAG_ALARMS_SUPPRESSED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterAlarmsStateChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BooleanStateConfigurationClusterAlarmsStateChangedEvent { tlvReader.enterStructure(tlvTag) val alarmsActive = tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_ACTIVE)) - val alarmsSuppressed = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) - } else { - Optional.empty() - } - + val alarmsSuppressed = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return BooleanStateConfigurationClusterAlarmsStateChangedEvent(alarmsActive, alarmsSuppressed) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt index 8349bb8fd86151..6232f56300e520 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BooleanStateConfigurationClusterSensorFaultEvent ( - val sensorFault: UInt) { - override fun toString(): String = buildString { +class BooleanStateConfigurationClusterSensorFaultEvent(val sensorFault: UInt) { + override fun toString(): String = buildString { append("BooleanStateConfigurationClusterSensorFaultEvent {\n") append("\tsensorFault : $sensorFault\n") append("}\n") @@ -45,10 +40,13 @@ class BooleanStateConfigurationClusterSensorFaultEvent ( companion object { private const val TAG_SENSOR_FAULT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterSensorFaultEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BooleanStateConfigurationClusterSensorFaultEvent { tlvReader.enterStructure(tlvTag) val sensorFault = tlvReader.getUInt(ContextSpecificTag(TAG_SENSOR_FAULT)) - + tlvReader.exitContainer() return BooleanStateConfigurationClusterSensorFaultEvent(sensorFault) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt index b5bbae742887b3..4a66dd930bf954 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BridgedDeviceBasicInformationClusterReachableChangedEvent ( - val reachableNewValue: Boolean) { - override fun toString(): String = buildString { +class BridgedDeviceBasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { + override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") append("}\n") @@ -45,10 +40,13 @@ class BridgedDeviceBasicInformationClusterReachableChangedEvent ( companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterReachableChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt index ac2c49d2929233..33e897ec0dcc9c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BridgedDeviceBasicInformationClusterStartUpEvent ( - val softwareVersion: ULong) { - override fun toString(): String = buildString { +class BridgedDeviceBasicInformationClusterStartUpEvent(val softwareVersion: ULong) { + override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("}\n") @@ -45,10 +40,13 @@ class BridgedDeviceBasicInformationClusterStartUpEvent ( companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterStartUpEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt index 788512180453b2..a4ab48a89bc770 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt @@ -17,27 +17,40 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent ( - val eventID: ByteArray, - val transitionIndex: UInt?, - val status: UInt, - val criticality: UInt, - val control: UInt, - val temperatureControl: Optional?, - val averageLoadControl: Optional?, - val dutyCycleControl: Optional?, - val powerSavingsControl: Optional?, - val heatingSourceControl: Optional?) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( + val eventID: ByteArray, + val transitionIndex: UInt?, + val status: UInt, + val criticality: UInt, + val control: UInt, + val temperatureControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct + >?, + val averageLoadControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct + >?, + val dutyCycleControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct + >?, + val powerSavingsControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct + >?, + val heatingSourceControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct + >? +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent {\n") append("\teventID : $eventID\n") append("\ttransitionIndex : $transitionIndex\n") @@ -57,53 +70,53 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_EVENT_I_D), eventID) if (transitionIndex != null) { - put(ContextSpecificTag(TAG_TRANSITION_INDEX), transitionIndex) - } else { - putNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) - } + put(ContextSpecificTag(TAG_TRANSITION_INDEX), transitionIndex) + } else { + putNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) + } put(ContextSpecificTag(TAG_STATUS), status) put(ContextSpecificTag(TAG_CRITICALITY), criticality) put(ContextSpecificTag(TAG_CONTROL), control) if (temperatureControl != null) { - if (temperatureControl.isPresent) { - val opttemperatureControl = temperatureControl.get() - opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) - } + if (temperatureControl.isPresent) { + val opttemperatureControl = temperatureControl.get() + opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) + } if (averageLoadControl != null) { - if (averageLoadControl.isPresent) { - val optaverageLoadControl = averageLoadControl.get() - optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) - } + if (averageLoadControl.isPresent) { + val optaverageLoadControl = averageLoadControl.get() + optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) + } if (dutyCycleControl != null) { - if (dutyCycleControl.isPresent) { - val optdutyCycleControl = dutyCycleControl.get() - optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) - } + if (dutyCycleControl.isPresent) { + val optdutyCycleControl = dutyCycleControl.get() + optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) + } if (powerSavingsControl != null) { - if (powerSavingsControl.isPresent) { - val optpowerSavingsControl = powerSavingsControl.get() - optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) - } + if (powerSavingsControl.isPresent) { + val optpowerSavingsControl = powerSavingsControl.get() + optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) + } if (heatingSourceControl != null) { - if (heatingSourceControl.isPresent) { - val optheatingSourceControl = heatingSourceControl.get() - optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) - } + if (heatingSourceControl.isPresent) { + val optheatingSourceControl = heatingSourceControl.get() + optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) + } endStructure() } } @@ -120,72 +133,112 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent ( private const val TAG_POWER_SAVINGS_CONTROL = 8 private const val TAG_HEATING_SOURCE_CONTROL = 9 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val transitionIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) - null - } + val transitionIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) + null + } val status = tlvReader.getUInt(ContextSpecificTag(TAG_STATUS)) val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) - null - } - val averageLoadControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) - null - } - val dutyCycleControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) - null - } - val powerSavingsControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) - null - } - val heatingSourceControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) - null - } - + val temperatureControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterTemperatureControlStruct + .fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) + null + } + val averageLoadControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterAverageLoadControlStruct + .fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) + null + } + val dutyCycleControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterDutyCycleControlStruct + .fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) + null + } + val powerSavingsControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterPowerSavingsControlStruct + .fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) + null + } + val heatingSourceControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterHeatingSourceControlStruct + .fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent(eventID, transitionIndex, status, criticality, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) + return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( + eventID, + transitionIndex, + status, + criticality, + control, + temperatureControl, + averageLoadControl, + dutyCycleControl, + powerSavingsControl, + heatingSourceControl + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt index 80397f205a2435..4bb96ee1c6026f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterPowerAdjustEndEvent ( - val cause: UInt, - val duration: ULong, - val energyUse: Long) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterPowerAdjustEndEvent( + val cause: UInt, + val duration: ULong, + val energyUse: Long +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterPowerAdjustEndEvent {\n") append("\tcause : $cause\n") append("\tduration : $duration\n") @@ -53,12 +50,15 @@ class DeviceEnergyManagementClusterPowerAdjustEndEvent ( private const val TAG_DURATION = 1 private const val TAG_ENERGY_USE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustEndEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterPowerAdjustEndEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) val energyUse = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_USE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterPowerAdjustEndEvent(cause, duration, energyUse) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt index 9d64e16ea5a9fd..5b4be5cfc2fd55 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterResumedEvent ( - val cause: UInt) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterResumedEvent(val cause: UInt) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterResumedEvent {\n") append("\tcause : $cause\n") append("}\n") @@ -45,10 +40,10 @@ class DeviceEnergyManagementClusterResumedEvent ( companion object { private const val TAG_CAUSE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterResumedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterResumedEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterResumedEvent(cause) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt index 71bdf0da0ad747..233b0d7030c8e5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DishwasherAlarmClusterNotifyEvent ( - val active: ULong, - val inactive: ULong, - val state: ULong, - val mask: ULong) { - override fun toString(): String = buildString { +class DishwasherAlarmClusterNotifyEvent( + val active: ULong, + val inactive: ULong, + val state: ULong, + val mask: ULong +) { + override fun toString(): String = buildString { append("DishwasherAlarmClusterNotifyEvent {\n") append("\tactive : $active\n") append("\tinactive : $inactive\n") @@ -57,13 +54,13 @@ class DishwasherAlarmClusterNotifyEvent ( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getULong(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getULong(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getULong(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getULong(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return DishwasherAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt index a64fa042cfcd15..918abe443473eb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterDoorLockAlarmEvent ( - val alarmCode: UInt) { - override fun toString(): String = buildString { +class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UInt) { + override fun toString(): String = buildString { append("DoorLockClusterDoorLockAlarmEvent {\n") append("\talarmCode : $alarmCode\n") append("}\n") @@ -45,10 +40,10 @@ class DoorLockClusterDoorLockAlarmEvent ( companion object { private const val TAG_ALARM_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorLockAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorLockAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmCode = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_CODE)) - + tlvReader.exitContainer() return DoorLockClusterDoorLockAlarmEvent(alarmCode) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt index bed611cb8674c0..64b69e7e205eb0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterDoorStateChangeEvent ( - val doorState: UInt) { - override fun toString(): String = buildString { +class DoorLockClusterDoorStateChangeEvent(val doorState: UInt) { + override fun toString(): String = buildString { append("DoorLockClusterDoorStateChangeEvent {\n") append("\tdoorState : $doorState\n") append("}\n") @@ -45,10 +40,10 @@ class DoorLockClusterDoorStateChangeEvent ( companion object { private const val TAG_DOOR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorStateChangeEvent { tlvReader.enterStructure(tlvTag) val doorState = tlvReader.getUInt(ContextSpecificTag(TAG_DOOR_STATE)) - + tlvReader.exitContainer() return DoorLockClusterDoorStateChangeEvent(doorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt index c57900a30d7946..d943e5d8ece7b8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt @@ -17,24 +17,24 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterLockOperationErrorEvent ( - val lockOperationType: UInt, - val operationSource: UInt, - val operationError: UInt, - val userIndex: UInt?, - val fabricIndex: UInt?, - val sourceNode: ULong?, - val credentials: Optional>?) { - override fun toString(): String = buildString { +class DoorLockClusterLockOperationErrorEvent( + val lockOperationType: UInt, + val operationSource: UInt, + val operationError: UInt, + val userIndex: UInt?, + val fabricIndex: UInt?, + val sourceNode: ULong?, + val credentials: + Optional>? +) { + override fun toString(): String = buildString { append("DoorLockClusterLockOperationErrorEvent {\n") append("\tlockOperationType : $lockOperationType\n") append("\toperationSource : $operationSource\n") @@ -53,32 +53,32 @@ class DoorLockClusterLockOperationErrorEvent ( put(ContextSpecificTag(TAG_OPERATION_SOURCE), operationSource) put(ContextSpecificTag(TAG_OPERATION_ERROR), operationError) if (userIndex != null) { - put(ContextSpecificTag(TAG_USER_INDEX), userIndex) - } else { - putNull(ContextSpecificTag(TAG_USER_INDEX)) - } + put(ContextSpecificTag(TAG_USER_INDEX), userIndex) + } else { + putNull(ContextSpecificTag(TAG_USER_INDEX)) + } if (fabricIndex != null) { - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - } else { - putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - } + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + } else { + putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + } if (sourceNode != null) { - put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) - } else { - putNull(ContextSpecificTag(TAG_SOURCE_NODE)) - } + put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) + } else { + putNull(ContextSpecificTag(TAG_SOURCE_NODE)) + } if (credentials != null) { - if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) + if (credentials.isPresent) { + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } + } else { + putNull(ContextSpecificTag(TAG_CREDENTIALS)) } - endArray() - } - } else { - putNull(ContextSpecificTag(TAG_CREDENTIALS)) - } endStructure() } } @@ -92,49 +92,68 @@ class DoorLockClusterLockOperationErrorEvent ( private const val TAG_SOURCE_NODE = 5 private const val TAG_CREDENTIALS = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationErrorEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) val operationError = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_ERROR)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while(!tlvReader.isEndOfContainer()) { - this.add(chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationErrorEvent(lockOperationType, operationSource, operationError, userIndex, fabricIndex, sourceNode, credentials) + return DoorLockClusterLockOperationErrorEvent( + lockOperationType, + operationSource, + operationError, + userIndex, + fabricIndex, + sourceNode, + credentials + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt index e86a8e434ee3ae..0e7c7e678bac46 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt @@ -17,23 +17,23 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterLockOperationEvent ( - val lockOperationType: UInt, - val operationSource: UInt, - val userIndex: UInt?, - val fabricIndex: UInt?, - val sourceNode: ULong?, - val credentials: Optional>?) { - override fun toString(): String = buildString { +class DoorLockClusterLockOperationEvent( + val lockOperationType: UInt, + val operationSource: UInt, + val userIndex: UInt?, + val fabricIndex: UInt?, + val sourceNode: ULong?, + val credentials: + Optional>? +) { + override fun toString(): String = buildString { append("DoorLockClusterLockOperationEvent {\n") append("\tlockOperationType : $lockOperationType\n") append("\toperationSource : $operationSource\n") @@ -50,32 +50,32 @@ class DoorLockClusterLockOperationEvent ( put(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE), lockOperationType) put(ContextSpecificTag(TAG_OPERATION_SOURCE), operationSource) if (userIndex != null) { - put(ContextSpecificTag(TAG_USER_INDEX), userIndex) - } else { - putNull(ContextSpecificTag(TAG_USER_INDEX)) - } + put(ContextSpecificTag(TAG_USER_INDEX), userIndex) + } else { + putNull(ContextSpecificTag(TAG_USER_INDEX)) + } if (fabricIndex != null) { - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - } else { - putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - } + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + } else { + putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + } if (sourceNode != null) { - put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) - } else { - putNull(ContextSpecificTag(TAG_SOURCE_NODE)) - } + put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) + } else { + putNull(ContextSpecificTag(TAG_SOURCE_NODE)) + } if (credentials != null) { - if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) + if (credentials.isPresent) { + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } + } else { + putNull(ContextSpecificTag(TAG_CREDENTIALS)) } - endArray() - } - } else { - putNull(ContextSpecificTag(TAG_CREDENTIALS)) - } endStructure() } } @@ -88,48 +88,66 @@ class DoorLockClusterLockOperationEvent ( private const val TAG_SOURCE_NODE = 4 private const val TAG_CREDENTIALS = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while(!tlvReader.isEndOfContainer()) { - this.add(chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationEvent(lockOperationType, operationSource, userIndex, fabricIndex, sourceNode, credentials) + return DoorLockClusterLockOperationEvent( + lockOperationType, + operationSource, + userIndex, + fabricIndex, + sourceNode, + credentials + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt index 7ef7dc4931b846..a5fc3f3725485e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt @@ -17,24 +17,21 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterLockUserChangeEvent ( - val lockDataType: UInt, - val dataOperationType: UInt, - val operationSource: UInt, - val userIndex: UInt?, - val fabricIndex: UInt?, - val sourceNode: ULong?, - val dataIndex: UInt?) { - override fun toString(): String = buildString { +class DoorLockClusterLockUserChangeEvent( + val lockDataType: UInt, + val dataOperationType: UInt, + val operationSource: UInt, + val userIndex: UInt?, + val fabricIndex: UInt?, + val sourceNode: ULong?, + val dataIndex: UInt? +) { + override fun toString(): String = buildString { append("DoorLockClusterLockUserChangeEvent {\n") append("\tlockDataType : $lockDataType\n") append("\tdataOperationType : $dataOperationType\n") @@ -53,25 +50,25 @@ class DoorLockClusterLockUserChangeEvent ( put(ContextSpecificTag(TAG_DATA_OPERATION_TYPE), dataOperationType) put(ContextSpecificTag(TAG_OPERATION_SOURCE), operationSource) if (userIndex != null) { - put(ContextSpecificTag(TAG_USER_INDEX), userIndex) - } else { - putNull(ContextSpecificTag(TAG_USER_INDEX)) - } + put(ContextSpecificTag(TAG_USER_INDEX), userIndex) + } else { + putNull(ContextSpecificTag(TAG_USER_INDEX)) + } if (fabricIndex != null) { - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - } else { - putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - } + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + } else { + putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + } if (sourceNode != null) { - put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) - } else { - putNull(ContextSpecificTag(TAG_SOURCE_NODE)) - } + put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) + } else { + putNull(ContextSpecificTag(TAG_SOURCE_NODE)) + } if (dataIndex != null) { - put(ContextSpecificTag(TAG_DATA_INDEX), dataIndex) - } else { - putNull(ContextSpecificTag(TAG_DATA_INDEX)) - } + put(ContextSpecificTag(TAG_DATA_INDEX), dataIndex) + } else { + putNull(ContextSpecificTag(TAG_DATA_INDEX)) + } endStructure() } } @@ -85,39 +82,51 @@ class DoorLockClusterLockUserChangeEvent ( private const val TAG_SOURCE_NODE = 5 private const val TAG_DATA_INDEX = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockUserChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockUserChangeEvent { tlvReader.enterStructure(tlvTag) val lockDataType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_DATA_TYPE)) val dataOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_DATA_OPERATION_TYPE)) val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val dataIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_DATA_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) - null - } - + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val dataIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_DATA_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockUserChangeEvent(lockDataType, dataOperationType, operationSource, userIndex, fabricIndex, sourceNode, dataIndex) + return DoorLockClusterLockUserChangeEvent( + lockDataType, + dataOperationType, + operationSource, + userIndex, + fabricIndex, + sourceNode, + dataIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt index 5ffcdf60628cff..8e0a4253bbc183 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt @@ -17,19 +17,23 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent ( - val energyImported: Optional, - val energyExported: Optional) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + val energyImported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent {\n") append("\tenergyImported : $energyImported\n") append("\tenergyExported : $energyExported\n") @@ -40,13 +44,13 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent ( tlvWriter.apply { startStructure(tlvTag) if (energyImported.isPresent) { - val optenergyImported = energyImported.get() - optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) - } + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } if (energyExported.isPresent) { - val optenergyExported = energyExported.get() - optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) - } + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } endStructure() } } @@ -55,22 +59,38 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent ( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) - } else { - Optional.empty() - } - val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) - } else { - Optional.empty() - } - + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent(energyImported, energyExported) + return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + energyImported, + energyExported + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt index b98ed116089884..a2ffd06d482dc8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt @@ -17,19 +17,23 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent ( - val energyImported: Optional, - val energyExported: Optional) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + val energyImported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent {\n") append("\tenergyImported : $energyImported\n") append("\tenergyExported : $energyExported\n") @@ -40,13 +44,13 @@ class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent ( tlvWriter.apply { startStructure(tlvTag) if (energyImported.isPresent) { - val optenergyImported = energyImported.get() - optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) - } + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } if (energyExported.isPresent) { - val optenergyExported = energyExported.get() - optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) - } + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } endStructure() } } @@ -55,22 +59,38 @@ class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent ( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) - } else { - Optional.empty() - } - val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) - } else { - Optional.empty() - } - + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent(energyImported, energyExported) + return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + energyImported, + energyExported + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt index 44302e41e8fec0..cc399a62cbc419 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt @@ -20,15 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent ( - val ranges: List) { - override fun toString(): String = buildString { +class ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent( + val ranges: + List< + chip.devicecontroller.cluster.structs.ElectricalPowerMeasurementClusterMeasurementRangeStruct + > +) { + override fun toString(): String = buildString { append("ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent {\n") append("\tranges : $ranges\n") append("}\n") @@ -49,16 +50,26 @@ class ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent ( companion object { private const val TAG_RANGES = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent { tlvReader.enterStructure(tlvTag) - val ranges = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RANGES)) - while(!tlvReader.isEndOfContainer()) { - this.add(chip.devicecontroller.cluster.structs.ElectricalPowerMeasurementClusterMeasurementRangeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val ranges = + buildList< + chip.devicecontroller.cluster.structs.ElectricalPowerMeasurementClusterMeasurementRangeStruct + > { + tlvReader.enterArray(ContextSpecificTag(TAG_RANGES)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs + .ElectricalPowerMeasurementClusterMeasurementRangeStruct + .fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent(ranges) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt index f7cf6196cf4937..37d91a3291a9f2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterEVConnectedEvent ( - val sessionID: ULong) { - override fun toString(): String = buildString { +class EnergyEvseClusterEVConnectedEvent(val sessionID: ULong) { + override fun toString(): String = buildString { append("EnergyEvseClusterEVConnectedEvent {\n") append("\tsessionID : $sessionID\n") append("}\n") @@ -45,10 +40,10 @@ class EnergyEvseClusterEVConnectedEvent ( companion object { private const val TAG_SESSION_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVConnectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVConnectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) - + tlvReader.exitContainer() return EnergyEvseClusterEVConnectedEvent(sessionID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt index f3e95efb7fcbfc..5720d4469df39c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterEVNotDetectedEvent ( - val sessionID: ULong, - val state: UInt, - val sessionDuration: ULong, - val sessionEnergyCharged: Long, - val sessionEnergyDischarged: Optional) { - override fun toString(): String = buildString { +class EnergyEvseClusterEVNotDetectedEvent( + val sessionID: ULong, + val state: UInt, + val sessionDuration: ULong, + val sessionEnergyCharged: Long, + val sessionEnergyDischarged: Optional +) { + override fun toString(): String = buildString { append("EnergyEvseClusterEVNotDetectedEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -50,9 +48,9 @@ class EnergyEvseClusterEVNotDetectedEvent ( put(ContextSpecificTag(TAG_SESSION_DURATION), sessionDuration) put(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED), sessionEnergyCharged) if (sessionEnergyDischarged.isPresent) { - val optsessionEnergyDischarged = sessionEnergyDischarged.get() - put(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED), optsessionEnergyDischarged) - } + val optsessionEnergyDischarged = sessionEnergyDischarged.get() + put(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED), optsessionEnergyDischarged) + } endStructure() } } @@ -64,21 +62,28 @@ class EnergyEvseClusterEVNotDetectedEvent ( private const val TAG_SESSION_ENERGY_CHARGED = 3 private const val TAG_SESSION_ENERGY_DISCHARGED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVNotDetectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVNotDetectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val sessionDuration = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_DURATION)) val sessionEnergyCharged = tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED)) - val sessionEnergyDischarged = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) - } else { - Optional.empty() - } - + val sessionEnergyDischarged = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterEVNotDetectedEvent(sessionID, state, sessionDuration, sessionEnergyCharged, sessionEnergyDischarged) + return EnergyEvseClusterEVNotDetectedEvent( + sessionID, + state, + sessionDuration, + sessionEnergyCharged, + sessionEnergyDischarged + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt index 29444bb45ec2c8..7843215518c11d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterEnergyTransferStartedEvent ( - val sessionID: ULong, - val state: UInt, - val maximumCurrent: Long) { - override fun toString(): String = buildString { +class EnergyEvseClusterEnergyTransferStartedEvent( + val sessionID: ULong, + val state: UInt, + val maximumCurrent: Long +) { + override fun toString(): String = buildString { append("EnergyEvseClusterEnergyTransferStartedEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -53,12 +50,12 @@ class EnergyEvseClusterEnergyTransferStartedEvent ( private const val TAG_STATE = 1 private const val TAG_MAXIMUM_CURRENT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStartedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStartedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val maximumCurrent = tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_CURRENT)) - + tlvReader.exitContainer() return EnergyEvseClusterEnergyTransferStartedEvent(sessionID, state, maximumCurrent) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt index ab277d74545a32..642bbc9b5e7a04 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterEnergyTransferStoppedEvent ( - val sessionID: ULong, - val state: UInt, - val reason: UInt, - val energyTransferred: Long) { - override fun toString(): String = buildString { +class EnergyEvseClusterEnergyTransferStoppedEvent( + val sessionID: ULong, + val state: UInt, + val reason: UInt, + val energyTransferred: Long +) { + override fun toString(): String = buildString { append("EnergyEvseClusterEnergyTransferStoppedEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -57,16 +54,21 @@ class EnergyEvseClusterEnergyTransferStoppedEvent ( private const val TAG_REASON = 2 private const val TAG_ENERGY_TRANSFERRED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStoppedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStoppedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val reason = tlvReader.getUInt(ContextSpecificTag(TAG_REASON)) val energyTransferred = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_TRANSFERRED)) - + tlvReader.exitContainer() - return EnergyEvseClusterEnergyTransferStoppedEvent(sessionID, state, reason, energyTransferred) + return EnergyEvseClusterEnergyTransferStoppedEvent( + sessionID, + state, + reason, + energyTransferred + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt index d95cc19e30fd92..53ca88273b038d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterFaultEvent ( - val sessionID: ULong?, - val state: UInt, - val faultStatePreviousState: UInt, - val faultStateCurrentState: UInt) { - override fun toString(): String = buildString { +class EnergyEvseClusterFaultEvent( + val sessionID: ULong?, + val state: UInt, + val faultStatePreviousState: UInt, + val faultStateCurrentState: UInt +) { + override fun toString(): String = buildString { append("EnergyEvseClusterFaultEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -44,10 +41,10 @@ class EnergyEvseClusterFaultEvent ( tlvWriter.apply { startStructure(tlvTag) if (sessionID != null) { - put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) - } else { - putNull(ContextSpecificTag(TAG_SESSION_I_D)) - } + put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) + } else { + putNull(ContextSpecificTag(TAG_SESSION_I_D)) + } put(ContextSpecificTag(TAG_STATE), state) put(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE), faultStatePreviousState) put(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE), faultStateCurrentState) @@ -61,21 +58,29 @@ class EnergyEvseClusterFaultEvent ( private const val TAG_FAULT_STATE_PREVIOUS_STATE = 2 private const val TAG_FAULT_STATE_CURRENT_STATE = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterFaultEvent { tlvReader.enterStructure(tlvTag) - val sessionID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) - null - } + val sessionID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) + null + } val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) - val faultStatePreviousState = tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) - val faultStateCurrentState = tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) - + val faultStatePreviousState = + tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) + val faultStateCurrentState = + tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) + tlvReader.exitContainer() - return EnergyEvseClusterFaultEvent(sessionID, state, faultStatePreviousState, faultStateCurrentState) + return EnergyEvseClusterFaultEvent( + sessionID, + state, + faultStatePreviousState, + faultStateCurrentState + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt index 13834fdaa5eb5b..760bc2cd92b2eb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterRFIDEvent ( - val uid: ByteArray) { - override fun toString(): String = buildString { +class EnergyEvseClusterRFIDEvent(val uid: ByteArray) { + override fun toString(): String = buildString { append("EnergyEvseClusterRFIDEvent {\n") append("\tuid : $uid\n") append("}\n") @@ -45,10 +40,10 @@ class EnergyEvseClusterRFIDEvent ( companion object { private const val TAG_UID = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterRFIDEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterRFIDEvent { tlvReader.enterStructure(tlvTag) val uid = tlvReader.getByteArray(ContextSpecificTag(TAG_UID)) - + tlvReader.exitContainer() return EnergyEvseClusterRFIDEvent(uid) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt index c3100ce31c6f9b..ab8a2c3ad964b4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterBootReasonEvent ( - val bootReason: UInt) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UInt) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterBootReasonEvent {\n") append("\tbootReason : $bootReason\n") append("}\n") @@ -45,10 +40,10 @@ class GeneralDiagnosticsClusterBootReasonEvent ( companion object { private const val TAG_BOOT_REASON = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterBootReasonEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterBootReasonEvent { tlvReader.enterStructure(tlvTag) val bootReason = tlvReader.getUInt(ContextSpecificTag(TAG_BOOT_REASON)) - + tlvReader.exitContainer() return GeneralDiagnosticsClusterBootReasonEvent(bootReason) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt index f93896c837f200..e09f3961230b34 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterHardwareFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterHardwareFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterHardwareFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,28 @@ class GeneralDiagnosticsClusterHardwareFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterHardwareFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralDiagnosticsClusterHardwareFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterHardwareFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt index ebc04643e795f2..2d17b1773194dc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterNetworkFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterNetworkFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterNetworkFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,28 @@ class GeneralDiagnosticsClusterNetworkFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt index 238e8657f6984b..3fc425674dde60 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterRadioFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterRadioFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterRadioFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,25 @@ class GeneralDiagnosticsClusterRadioFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterRadioFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterRadioFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterRadioFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt index c8127f90ae7b9c..8626f9daed4e01 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt @@ -17,26 +17,25 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaPlaybackClusterStateChangedEvent ( - val currentState: UInt, - val startTime: ULong, - val duration: ULong, - val sampledPosition: chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct, - val playbackSpeed: Float, - val seekRangeEnd: ULong, - val seekRangeStart: ULong, - val data: Optional, - val audioAdvanceUnmuted: Boolean) { - override fun toString(): String = buildString { +class MediaPlaybackClusterStateChangedEvent( + val currentState: UInt, + val startTime: ULong, + val duration: ULong, + val sampledPosition: + chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct, + val playbackSpeed: Float, + val seekRangeEnd: ULong, + val seekRangeStart: ULong, + val data: Optional, + val audioAdvanceUnmuted: Boolean +) { + override fun toString(): String = buildString { append("MediaPlaybackClusterStateChangedEvent {\n") append("\tcurrentState : $currentState\n") append("\tstartTime : $startTime\n") @@ -61,9 +60,9 @@ class MediaPlaybackClusterStateChangedEvent ( put(ContextSpecificTag(TAG_SEEK_RANGE_END), seekRangeEnd) put(ContextSpecificTag(TAG_SEEK_RANGE_START), seekRangeStart) if (data.isPresent) { - val optdata = data.get() - put(ContextSpecificTag(TAG_DATA), optdata) - } + val optdata = data.get() + put(ContextSpecificTag(TAG_DATA), optdata) + } put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED), audioAdvanceUnmuted) endStructure() } @@ -80,25 +79,40 @@ class MediaPlaybackClusterStateChangedEvent ( private const val TAG_DATA = 7 private const val TAG_AUDIO_ADVANCE_UNMUTED = 8 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val currentState = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_STATE)) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - val sampledPosition = chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv(ContextSpecificTag(TAG_SAMPLED_POSITION), tlvReader) + val sampledPosition = + chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv( + ContextSpecificTag(TAG_SAMPLED_POSITION), + tlvReader + ) val playbackSpeed = tlvReader.getFloat(ContextSpecificTag(TAG_PLAYBACK_SPEED)) val seekRangeEnd = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_END)) val seekRangeStart = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_START)) - val data = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) - } else { - Optional.empty() - } + val data = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) + } else { + Optional.empty() + } val audioAdvanceUnmuted = tlvReader.getBoolean(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED)) - + tlvReader.exitContainer() - return MediaPlaybackClusterStateChangedEvent(currentState, startTime, duration, sampledPosition, playbackSpeed, seekRangeEnd, seekRangeStart, data, audioAdvanceUnmuted) + return MediaPlaybackClusterStateChangedEvent( + currentState, + startTime, + duration, + sampledPosition, + playbackSpeed, + seekRangeEnd, + seekRangeStart, + data, + audioAdvanceUnmuted + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessageCompleteEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessageCompleteEvent.kt index 50dda5b2e349c8..d885f26d3d9b8b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessageCompleteEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessageCompleteEvent.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MessagesClusterMessageCompleteEvent ( - val messageID: ByteArray, - val responseID: Optional?, - val reply: Optional?, - val futureMessagesPreference: UInt?) { - override fun toString(): String = buildString { +class MessagesClusterMessageCompleteEvent( + val messageID: ByteArray, + val responseID: Optional?, + val reply: Optional?, + val futureMessagesPreference: UInt? +) { + override fun toString(): String = buildString { append("MessagesClusterMessageCompleteEvent {\n") append("\tmessageID : $messageID\n") append("\tresponseID : $responseID\n") @@ -45,26 +43,26 @@ class MessagesClusterMessageCompleteEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_MESSAGE_I_D), messageID) if (responseID != null) { - if (responseID.isPresent) { - val optresponseID = responseID.get() - put(ContextSpecificTag(TAG_RESPONSE_I_D), optresponseID) - } - } else { - putNull(ContextSpecificTag(TAG_RESPONSE_I_D)) - } + if (responseID.isPresent) { + val optresponseID = responseID.get() + put(ContextSpecificTag(TAG_RESPONSE_I_D), optresponseID) + } + } else { + putNull(ContextSpecificTag(TAG_RESPONSE_I_D)) + } if (reply != null) { - if (reply.isPresent) { - val optreply = reply.get() - put(ContextSpecificTag(TAG_REPLY), optreply) - } - } else { - putNull(ContextSpecificTag(TAG_REPLY)) - } + if (reply.isPresent) { + val optreply = reply.get() + put(ContextSpecificTag(TAG_REPLY), optreply) + } + } else { + putNull(ContextSpecificTag(TAG_REPLY)) + } if (futureMessagesPreference != null) { - put(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE), futureMessagesPreference) - } else { - putNull(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) - } + put(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE), futureMessagesPreference) + } else { + putNull(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) + } endStructure() } } @@ -75,39 +73,47 @@ class MessagesClusterMessageCompleteEvent ( private const val TAG_REPLY = 2 private const val TAG_FUTURE_MESSAGES_PREFERENCE = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MessagesClusterMessageCompleteEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessageCompleteEvent { tlvReader.enterStructure(tlvTag) val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D)) - val responseID = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSE_I_D))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RESPONSE_I_D))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RESPONSE_I_D)) - null - } - val reply = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_REPLY))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_REPLY))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_REPLY)) - null - } - val futureMessagesPreference = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) - null - } - + val responseID = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSE_I_D))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RESPONSE_I_D))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RESPONSE_I_D)) + null + } + val reply = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_REPLY))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_REPLY))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_REPLY)) + null + } + val futureMessagesPreference = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) + null + } + tlvReader.exitContainer() - return MessagesClusterMessageCompleteEvent(messageID, responseID, reply, futureMessagesPreference) + return MessagesClusterMessageCompleteEvent( + messageID, + responseID, + reply, + futureMessagesPreference + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessagePresentedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessagePresentedEvent.kt index 3ba51595b78219..a2e39882f9ab4a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessagePresentedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessagePresentedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MessagesClusterMessagePresentedEvent ( - val messageID: ByteArray) { - override fun toString(): String = buildString { +class MessagesClusterMessagePresentedEvent(val messageID: ByteArray) { + override fun toString(): String = buildString { append("MessagesClusterMessagePresentedEvent {\n") append("\tmessageID : $messageID\n") append("}\n") @@ -45,10 +40,10 @@ class MessagesClusterMessagePresentedEvent ( companion object { private const val TAG_MESSAGE_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MessagesClusterMessagePresentedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessagePresentedEvent { tlvReader.enterStructure(tlvTag) val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D)) - + tlvReader.exitContainer() return MessagesClusterMessagePresentedEvent(messageID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessageQueuedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessageQueuedEvent.kt index 5f06909543cfe8..db5ed28fae6de0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessageQueuedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MessagesClusterMessageQueuedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MessagesClusterMessageQueuedEvent ( - val messageID: ByteArray) { - override fun toString(): String = buildString { +class MessagesClusterMessageQueuedEvent(val messageID: ByteArray) { + override fun toString(): String = buildString { append("MessagesClusterMessageQueuedEvent {\n") append("\tmessageID : $messageID\n") append("}\n") @@ -45,10 +40,10 @@ class MessagesClusterMessageQueuedEvent ( companion object { private const val TAG_MESSAGE_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MessagesClusterMessageQueuedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessageQueuedEvent { tlvReader.enterStructure(tlvTag) val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D)) - + tlvReader.exitContainer() return MessagesClusterMessageQueuedEvent(messageID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt index bd2f7895bfd1e2..95cf699d416744 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalStateClusterOperationCompletionEvent ( - val completionErrorCode: UInt, - val totalOperationalTime: Optional?, - val pausedTime: Optional?) { - override fun toString(): String = buildString { +class OperationalStateClusterOperationCompletionEvent( + val completionErrorCode: UInt, + val totalOperationalTime: Optional?, + val pausedTime: Optional? +) { + override fun toString(): String = buildString { append("OperationalStateClusterOperationCompletionEvent {\n") append("\tcompletionErrorCode : $completionErrorCode\n") append("\ttotalOperationalTime : $totalOperationalTime\n") @@ -43,21 +41,21 @@ class OperationalStateClusterOperationCompletionEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (pausedTime != null) { - if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } - } else { - putNull(ContextSpecificTag(TAG_PAUSED_TIME)) - } + if (pausedTime.isPresent) { + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } + } else { + putNull(ContextSpecificTag(TAG_PAUSED_TIME)) + } endStructure() } } @@ -67,33 +65,42 @@ class OperationalStateClusterOperationCompletionEvent ( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return OperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt index f0cd196223d72c..4ff0719f3d0f3b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt @@ -17,18 +17,15 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalStateClusterOperationalErrorEvent ( - val errorState: chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct) { - override fun toString(): String = buildString { +class OperationalStateClusterOperationalErrorEvent( + val errorState: chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct +) { + override fun toString(): String = buildString { append("OperationalStateClusterOperationalErrorEvent {\n") append("\terrorState : $errorState\n") append("}\n") @@ -45,10 +42,14 @@ class OperationalStateClusterOperationalErrorEvent ( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return OperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt index 67e9047f0532a4..8156c9578afadc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent ( - val softwareVersion: ULong, - val bytesDownloaded: ULong, - val progressPercent: UInt?, - val platformCode: Long?) { - override fun toString(): String = buildString { +class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( + val softwareVersion: ULong, + val bytesDownloaded: ULong, + val progressPercent: UInt?, + val platformCode: Long? +) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterDownloadErrorEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("\tbytesDownloaded : $bytesDownloaded\n") @@ -46,15 +43,15 @@ class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent ( put(ContextSpecificTag(TAG_SOFTWARE_VERSION), softwareVersion) put(ContextSpecificTag(TAG_BYTES_DOWNLOADED), bytesDownloaded) if (progressPercent != null) { - put(ContextSpecificTag(TAG_PROGRESS_PERCENT), progressPercent) - } else { - putNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - } + put(ContextSpecificTag(TAG_PROGRESS_PERCENT), progressPercent) + } else { + putNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + } if (platformCode != null) { - put(ContextSpecificTag(TAG_PLATFORM_CODE), platformCode) - } else { - putNull(ContextSpecificTag(TAG_PLATFORM_CODE)) - } + put(ContextSpecificTag(TAG_PLATFORM_CODE), platformCode) + } else { + putNull(ContextSpecificTag(TAG_PLATFORM_CODE)) + } endStructure() } } @@ -65,26 +62,36 @@ class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent ( private const val TAG_PROGRESS_PERCENT = 2 private const val TAG_PLATFORM_CODE = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val bytesDownloaded = tlvReader.getULong(ContextSpecificTag(TAG_BYTES_DOWNLOADED)) - val progressPercent = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - null - } - val platformCode = if (!tlvReader.isNull()) { - tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) - null - } - + val progressPercent = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + null + } + val platformCode = + if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent(softwareVersion, bytesDownloaded, progressPercent, platformCode) + return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( + softwareVersion, + bytesDownloaded, + progressPercent, + platformCode + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt index 99acba4d90a2dd..3843fe8b3b782a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OtaSoftwareUpdateRequestorClusterStateTransitionEvent ( - val previousState: UInt, - val newState: UInt, - val reason: UInt, - val targetSoftwareVersion: ULong?) { - override fun toString(): String = buildString { +class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( + val previousState: UInt, + val newState: UInt, + val reason: UInt, + val targetSoftwareVersion: ULong? +) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterStateTransitionEvent {\n") append("\tpreviousState : $previousState\n") append("\tnewState : $newState\n") @@ -47,10 +44,10 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent ( put(ContextSpecificTag(TAG_NEW_STATE), newState) put(ContextSpecificTag(TAG_REASON), reason) if (targetSoftwareVersion != null) { - put(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION), targetSoftwareVersion) - } else { - putNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - } + put(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION), targetSoftwareVersion) + } else { + putNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + } endStructure() } } @@ -61,21 +58,30 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent ( private const val TAG_REASON = 2 private const val TAG_TARGET_SOFTWARE_VERSION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterStateTransitionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterStateTransitionEvent { tlvReader.enterStructure(tlvTag) val previousState = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_STATE)) val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) val reason = tlvReader.getUInt(ContextSpecificTag(TAG_REASON)) - val targetSoftwareVersion = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - null - } - + val targetSoftwareVersion = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterStateTransitionEvent(previousState, newState, reason, targetSoftwareVersion) + return OtaSoftwareUpdateRequestorClusterStateTransitionEvent( + previousState, + newState, + reason, + targetSoftwareVersion + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt index 50dda1eeae85db..43ec6b74bfc442 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent ( - val softwareVersion: ULong, - val productID: UInt) { - override fun toString(): String = buildString { +class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent( + val softwareVersion: ULong, + val productID: UInt +) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterVersionAppliedEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("\tproductID : $productID\n") @@ -49,11 +46,14 @@ class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent ( private const val TAG_SOFTWARE_VERSION = 0 private const val TAG_PRODUCT_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val productID = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_I_D)) - + tlvReader.exitContainer() return OtaSoftwareUpdateRequestorClusterVersionAppliedEvent(softwareVersion, productID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt index c823fe799eb82b..b5a235e97841ba 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenCavityOperationalStateClusterOperationCompletionEvent ( - val completionErrorCode: UInt, - val totalOperationalTime: Optional?, - val pausedTime: Optional?) { - override fun toString(): String = buildString { +class OvenCavityOperationalStateClusterOperationCompletionEvent( + val completionErrorCode: UInt, + val totalOperationalTime: Optional?, + val pausedTime: Optional? +) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationCompletionEvent {\n") append("\tcompletionErrorCode : $completionErrorCode\n") append("\ttotalOperationalTime : $totalOperationalTime\n") @@ -43,21 +41,21 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (pausedTime != null) { - if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } - } else { - putNull(ContextSpecificTag(TAG_PAUSED_TIME)) - } + if (pausedTime.isPresent) { + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } + } else { + putNull(ContextSpecificTag(TAG_PAUSED_TIME)) + } endStructure() } } @@ -67,33 +65,42 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent ( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return OvenCavityOperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt index 9ba1604dedd97a..8b1b9345a7df0b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt @@ -17,18 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenCavityOperationalStateClusterOperationalErrorEvent ( - val errorState: chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct) { - override fun toString(): String = buildString { +class OvenCavityOperationalStateClusterOperationalErrorEvent( + val errorState: + chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct +) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalErrorEvent {\n") append("\terrorState : $errorState\n") append("}\n") @@ -45,10 +43,15 @@ class OvenCavityOperationalStateClusterOperationalErrorEvent ( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationalErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct + .fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) + tlvReader.exitContainer() return OvenCavityOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt index b09829b20efd50..fdb0b033a7616a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterBatChargeFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterBatChargeFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("PowerSourceClusterBatChargeFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,25 @@ class PowerSourceClusterBatChargeFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatChargeFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt index ef4689fff56f84..7a5d133299cef5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt @@ -20,16 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterBatFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterBatFaultChangeEvent(val current: List, val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +52,25 @@ class PowerSourceClusterBatFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt index 5062e14fc47019..1f004191d406f0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt @@ -20,16 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterWiredFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +52,25 @@ class PowerSourceClusterWiredFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterWiredFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt index 0d0ec7f29f122c..2584478cd02e39 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RefrigeratorAlarmClusterNotifyEvent ( - val active: ULong, - val inactive: ULong, - val state: ULong, - val mask: ULong) { - override fun toString(): String = buildString { +class RefrigeratorAlarmClusterNotifyEvent( + val active: ULong, + val inactive: ULong, + val state: ULong, + val mask: ULong +) { + override fun toString(): String = buildString { append("RefrigeratorAlarmClusterNotifyEvent {\n") append("\tactive : $active\n") append("\tinactive : $inactive\n") @@ -57,13 +54,13 @@ class RefrigeratorAlarmClusterNotifyEvent ( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getULong(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getULong(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getULong(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getULong(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return RefrigeratorAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt index a9817567e22677..cfea1b82753b91 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcOperationalStateClusterOperationCompletionEvent ( - val completionErrorCode: UInt, - val totalOperationalTime: Optional?, - val pausedTime: Optional?) { - override fun toString(): String = buildString { +class RvcOperationalStateClusterOperationCompletionEvent( + val completionErrorCode: UInt, + val totalOperationalTime: Optional?, + val pausedTime: Optional? +) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationCompletionEvent {\n") append("\tcompletionErrorCode : $completionErrorCode\n") append("\ttotalOperationalTime : $totalOperationalTime\n") @@ -43,21 +41,21 @@ class RvcOperationalStateClusterOperationCompletionEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (pausedTime != null) { - if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } - } else { - putNull(ContextSpecificTag(TAG_PAUSED_TIME)) - } + if (pausedTime.isPresent) { + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } + } else { + putNull(ContextSpecificTag(TAG_PAUSED_TIME)) + } endStructure() } } @@ -67,33 +65,42 @@ class RvcOperationalStateClusterOperationCompletionEvent ( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return RvcOperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt index 406ef9431645cd..6ad8a5e8875408 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt @@ -17,18 +17,15 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcOperationalStateClusterOperationalErrorEvent ( - val errorState: chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct) { - override fun toString(): String = buildString { +class RvcOperationalStateClusterOperationalErrorEvent( + val errorState: chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct +) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationalErrorEvent {\n") append("\terrorState : $errorState\n") append("}\n") @@ -45,10 +42,17 @@ class RvcOperationalStateClusterOperationalErrorEvent ( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationalErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return RvcOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt index 03b105c427a397..a0588f4ad66d56 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SampleMeiClusterPingCountEventEvent ( - val count: ULong, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class SampleMeiClusterPingCountEventEvent(val count: ULong, val fabricIndex: UInt) { + override fun toString(): String = buildString { append("SampleMeiClusterPingCountEventEvent {\n") append("\tcount : $count\n") append("\tfabricIndex : $fabricIndex\n") @@ -49,11 +43,11 @@ class SampleMeiClusterPingCountEventEvent ( private const val TAG_COUNT = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SampleMeiClusterPingCountEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { tlvReader.enterStructure(tlvTag) val count = tlvReader.getULong(ContextSpecificTag(TAG_COUNT)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return SampleMeiClusterPingCountEventEvent(count, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt index 48acd74033fca2..a34090499ca233 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterCOAlarmEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterCOAlarmEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt index 685a6ab5fc1059..c3ec4fbf491c87 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterInterconnectCOAlarmEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterInterconnectCOAlarmEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt index 1fb60bf24aec59..3957d722ade622 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt index 91345969b757b4..e855a9391a7491 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterLowBatteryEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterLowBatteryEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterLowBatteryEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterLowBatteryEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterLowBatteryEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterLowBatteryEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt index 3494dffe4f3d5b..5e5ff96385c265 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterSmokeAlarmEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterSmokeAlarmEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt index b0e0d4844fadca..d3389bbaf8f367 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SoftwareDiagnosticsClusterSoftwareFaultEvent ( - val id: ULong, - val name: Optional, - val faultRecording: Optional) { - override fun toString(): String = buildString { +class SoftwareDiagnosticsClusterSoftwareFaultEvent( + val id: ULong, + val name: Optional, + val faultRecording: Optional +) { + override fun toString(): String = buildString { append("SoftwareDiagnosticsClusterSoftwareFaultEvent {\n") append("\tid : $id\n") append("\tname : $name\n") @@ -43,13 +41,13 @@ class SoftwareDiagnosticsClusterSoftwareFaultEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ID), id) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (faultRecording.isPresent) { - val optfaultRecording = faultRecording.get() - put(ContextSpecificTag(TAG_FAULT_RECORDING), optfaultRecording) - } + val optfaultRecording = faultRecording.get() + put(ContextSpecificTag(TAG_FAULT_RECORDING), optfaultRecording) + } endStructure() } } @@ -59,20 +57,22 @@ class SoftwareDiagnosticsClusterSoftwareFaultEvent ( private const val TAG_NAME = 1 private const val TAG_FAULT_RECORDING = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SoftwareDiagnosticsClusterSoftwareFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterSoftwareFaultEvent { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val faultRecording = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val faultRecording = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return SoftwareDiagnosticsClusterSoftwareFaultEvent(id, name, faultRecording) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt index fa3cf254ebdb96..965bc1a81af5ac 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterInitialPressEvent ( - val newPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterInitialPressEvent(val newPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterInitialPressEvent {\n") append("\tnewPosition : $newPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterInitialPressEvent ( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterInitialPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterInitialPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterInitialPressEvent(newPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt index 2748e8e6a44449..e986ef1d8d97fe 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterLongPressEvent ( - val newPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterLongPressEvent(val newPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterLongPressEvent {\n") append("\tnewPosition : $newPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterLongPressEvent ( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongPressEvent(newPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt index f4661d48d8e63e..e99b119d906e8b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterLongReleaseEvent ( - val previousPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterLongReleaseEvent(val previousPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterLongReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterLongReleaseEvent ( companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt index b5d580a7cf0c55..381ec17ae29ac5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterMultiPressCompleteEvent ( - val previousPosition: UInt, - val totalNumberOfPressesCounted: UInt) { - override fun toString(): String = buildString { +class SwitchClusterMultiPressCompleteEvent( + val previousPosition: UInt, + val totalNumberOfPressesCounted: UInt +) { + override fun toString(): String = buildString { append("SwitchClusterMultiPressCompleteEvent {\n") append("\tpreviousPosition : $previousPosition\n") append("\ttotalNumberOfPressesCounted : $totalNumberOfPressesCounted\n") @@ -49,11 +46,12 @@ class SwitchClusterMultiPressCompleteEvent ( private const val TAG_PREVIOUS_POSITION = 0 private const val TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressCompleteEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressCompleteEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - val totalNumberOfPressesCounted = tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) - + val totalNumberOfPressesCounted = + tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressCompleteEvent(previousPosition, totalNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt index fcaf6c0ca5ef5f..dd904f59cb9fdc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterMultiPressOngoingEvent ( - val newPosition: UInt, - val currentNumberOfPressesCounted: UInt) { - override fun toString(): String = buildString { +class SwitchClusterMultiPressOngoingEvent( + val newPosition: UInt, + val currentNumberOfPressesCounted: UInt +) { + override fun toString(): String = buildString { append("SwitchClusterMultiPressOngoingEvent {\n") append("\tnewPosition : $newPosition\n") append("\tcurrentNumberOfPressesCounted : $currentNumberOfPressesCounted\n") @@ -49,11 +46,12 @@ class SwitchClusterMultiPressOngoingEvent ( private const val TAG_NEW_POSITION = 0 private const val TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressOngoingEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressOngoingEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - val currentNumberOfPressesCounted = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) - + val currentNumberOfPressesCounted = + tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressOngoingEvent(newPosition, currentNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt index 91a786b4f78740..477dc53e895a2a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterShortReleaseEvent ( - val previousPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterShortReleaseEvent(val previousPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterShortReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterShortReleaseEvent ( companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterShortReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterShortReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterShortReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt index f6537ab66e931a..6a2ea4883e4f6f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterSwitchLatchedEvent ( - val newPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterSwitchLatchedEvent(val newPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterSwitchLatchedEvent {\n") append("\tnewPosition : $newPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterSwitchLatchedEvent ( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterSwitchLatchedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterSwitchLatchedEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterSwitchLatchedEvent(newPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt index e49f93ead0165f..ce5bbb1df841c9 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt @@ -20,17 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TargetNavigatorClusterTargetUpdatedEvent ( - val targetList: List, - val currentTarget: UInt, - val data: ByteArray) { - override fun toString(): String = buildString { +class TargetNavigatorClusterTargetUpdatedEvent( + val targetList: + List, + val currentTarget: UInt, + val data: ByteArray +) { + override fun toString(): String = buildString { append("TargetNavigatorClusterTargetUpdatedEvent {\n") append("\ttargetList : $targetList\n") append("\tcurrentTarget : $currentTarget\n") @@ -57,18 +56,24 @@ class TargetNavigatorClusterTargetUpdatedEvent ( private const val TAG_CURRENT_TARGET = 1 private const val TAG_DATA = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TargetNavigatorClusterTargetUpdatedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetUpdatedEvent { tlvReader.enterStructure(tlvTag) - val targetList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) - while(!tlvReader.isEndOfContainer()) { - this.add(chip.devicecontroller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val targetList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } val currentTarget = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_TARGET)) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetUpdatedEvent(targetList, currentTarget, data) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt index 7a9290a163f25e..dc55e372090536 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterConnectionStatusEvent ( - val connectionStatus: UInt) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UInt) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") append("}\n") @@ -45,10 +40,13 @@ class ThreadNetworkDiagnosticsClusterConnectionStatusEvent ( companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUInt(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt index 384675b471a0d6..f2ce60e4c710ba 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,28 @@ class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDirectoryClusterNetworkChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDirectoryClusterNetworkChangedEvent.kt index e7ad1a95aeab59..df86cf8e4f6f47 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDirectoryClusterNetworkChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDirectoryClusterNetworkChangedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDirectoryClusterNetworkChangedEvent ( - val extendedPanID: ULong) { - override fun toString(): String = buildString { +class ThreadNetworkDirectoryClusterNetworkChangedEvent(val extendedPanID: ULong) { + override fun toString(): String = buildString { append("ThreadNetworkDirectoryClusterNetworkChangedEvent {\n") append("\textendedPanID : $extendedPanID\n") append("}\n") @@ -45,10 +40,13 @@ class ThreadNetworkDirectoryClusterNetworkChangedEvent ( companion object { private const val TAG_EXTENDED_PAN_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDirectoryClusterNetworkChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDirectoryClusterNetworkChangedEvent { tlvReader.enterStructure(tlvTag) val extendedPanID = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_I_D)) - + tlvReader.exitContainer() return ThreadNetworkDirectoryClusterNetworkChangedEvent(extendedPanID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt index d4162a1dd3f5ae..7564293e97be61 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterDSTStatusEvent ( - val DSTOffsetActive: Boolean) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterDSTStatusEvent(val DSTOffsetActive: Boolean) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterDSTStatusEvent {\n") append("\tDSTOffsetActive : $DSTOffsetActive\n") append("}\n") @@ -45,10 +40,10 @@ class TimeSynchronizationClusterDSTStatusEvent ( companion object { private const val TAG_D_S_T_OFFSET_ACTIVE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterDSTStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterDSTStatusEvent { tlvReader.enterStructure(tlvTag) val DSTOffsetActive = tlvReader.getBoolean(ContextSpecificTag(TAG_D_S_T_OFFSET_ACTIVE)) - + tlvReader.exitContainer() return TimeSynchronizationClusterDSTStatusEvent(DSTOffsetActive) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt index 52b2b4fd1e1dfa..9e9d5ef9f1355f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterTimeZoneStatusEvent ( - val offset: Long, - val name: Optional) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterTimeZoneStatusEvent(val offset: Long, val name: Optional) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterTimeZoneStatusEvent {\n") append("\toffset : $offset\n") append("\tname : $name\n") @@ -41,9 +36,9 @@ class TimeSynchronizationClusterTimeZoneStatusEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OFFSET), offset) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } endStructure() } } @@ -52,15 +47,16 @@ class TimeSynchronizationClusterTimeZoneStatusEvent ( private const val TAG_OFFSET = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTimeZoneStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTimeZoneStatusEvent { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getLong(ContextSpecificTag(TAG_OFFSET)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStatusEvent(offset, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestDifferentVendorMeiEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestDifferentVendorMeiEventEvent.kt index 25888f96b384ea..034966430b11c4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestDifferentVendorMeiEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestDifferentVendorMeiEventEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterTestDifferentVendorMeiEventEvent ( - val arg1: UInt) { - override fun toString(): String = buildString { +class UnitTestingClusterTestDifferentVendorMeiEventEvent(val arg1: UInt) { + override fun toString(): String = buildString { append("UnitTestingClusterTestDifferentVendorMeiEventEvent {\n") append("\targ1 : $arg1\n") append("}\n") @@ -45,10 +40,13 @@ class UnitTestingClusterTestDifferentVendorMeiEventEvent ( companion object { private const val TAG_ARG1 = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestDifferentVendorMeiEventEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): UnitTestingClusterTestDifferentVendorMeiEventEvent { tlvReader.enterStructure(tlvTag) val arg1 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG1)) - + tlvReader.exitContainer() return UnitTestingClusterTestDifferentVendorMeiEventEvent(arg1) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt index 89dbdc9593b84e..d92c0b6b531a6b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt @@ -20,20 +20,18 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterTestEventEvent ( - val arg1: UInt, - val arg2: UInt, - val arg3: Boolean, - val arg4: chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct, - val arg5: List, - val arg6: List) { - override fun toString(): String = buildString { +class UnitTestingClusterTestEventEvent( + val arg1: UInt, + val arg2: UInt, + val arg3: Boolean, + val arg4: chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct, + val arg5: List, + val arg6: List +) { + override fun toString(): String = buildString { append("UnitTestingClusterTestEventEvent {\n") append("\targ1 : $arg1\n") append("\targ2 : $arg2\n") @@ -73,27 +71,38 @@ class UnitTestingClusterTestEventEvent ( private const val TAG_ARG5 = 5 private const val TAG_ARG6 = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestEventEvent { tlvReader.enterStructure(tlvTag) val arg1 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG1)) val arg2 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG2)) val arg3 = tlvReader.getBoolean(ContextSpecificTag(TAG_ARG3)) - val arg4 = chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_ARG4), tlvReader) - val arg5 = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) - while(!tlvReader.isEndOfContainer()) { - this.add(chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val arg6 = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val arg4 = + chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_ARG4), + tlvReader + ) + val arg5 = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + val arg6 = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterTestEventEvent(arg1, arg2, arg3, arg4, arg5, arg6) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt index b71c9c788a3a76..b6cc1c77125923 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterTestFabricScopedEventEvent ( - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class UnitTestingClusterTestFabricScopedEventEvent(val fabricIndex: UInt) { + override fun toString(): String = buildString { append("UnitTestingClusterTestFabricScopedEventEvent {\n") append("\tfabricIndex : $fabricIndex\n") append("}\n") @@ -45,10 +40,10 @@ class UnitTestingClusterTestFabricScopedEventEvent ( companion object { private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestFabricScopedEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScopedEventEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return UnitTestingClusterTestFabricScopedEventEvent(fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt index cead9f186377e2..cb432d975e1275 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ValveConfigurationAndControlClusterValveFaultEvent ( - val valveFault: UInt) { - override fun toString(): String = buildString { +class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UInt) { + override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveFaultEvent {\n") append("\tvalveFault : $valveFault\n") append("}\n") @@ -45,10 +40,13 @@ class ValveConfigurationAndControlClusterValveFaultEvent ( companion object { private const val TAG_VALVE_FAULT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveFaultEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ValveConfigurationAndControlClusterValveFaultEvent { tlvReader.enterStructure(tlvTag) val valveFault = tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_FAULT)) - + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveFaultEvent(valveFault) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt index d8714935057610..e34e14aee60c7d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ValveConfigurationAndControlClusterValveStateChangedEvent ( - val valveState: UInt, - val valveLevel: Optional) { - override fun toString(): String = buildString { +class ValveConfigurationAndControlClusterValveStateChangedEvent( + val valveState: UInt, + val valveLevel: Optional +) { + override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveStateChangedEvent {\n") append("\tvalveState : $valveState\n") append("\tvalveLevel : $valveLevel\n") @@ -41,9 +39,9 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_VALVE_STATE), valveState) if (valveLevel.isPresent) { - val optvalveLevel = valveLevel.get() - put(ContextSpecificTag(TAG_VALVE_LEVEL), optvalveLevel) - } + val optvalveLevel = valveLevel.get() + put(ContextSpecificTag(TAG_VALVE_LEVEL), optvalveLevel) + } endStructure() } } @@ -52,15 +50,19 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent ( private const val TAG_VALVE_STATE = 0 private const val TAG_VALVE_LEVEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveStateChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ValveConfigurationAndControlClusterValveStateChangedEvent { tlvReader.enterStructure(tlvTag) val valveState = tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_STATE)) - val valveLevel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_LEVEL))) - } else { - Optional.empty() - } - + val valveLevel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_LEVEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveStateChangedEvent(valveState, valveLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt index 353230c4664dc5..2f94dc8e6b1c58 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class WiFiNetworkDiagnosticsClusterAssociationFailureEvent ( - val associationFailureCause: UInt, - val status: UInt) { - override fun toString(): String = buildString { +class WiFiNetworkDiagnosticsClusterAssociationFailureEvent( + val associationFailureCause: UInt, + val status: UInt +) { + override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterAssociationFailureEvent {\n") append("\tassociationFailureCause : $associationFailureCause\n") append("\tstatus : $status\n") @@ -49,11 +46,15 @@ class WiFiNetworkDiagnosticsClusterAssociationFailureEvent ( private const val TAG_ASSOCIATION_FAILURE_CAUSE = 0 private const val TAG_STATUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterAssociationFailureEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterAssociationFailureEvent { tlvReader.enterStructure(tlvTag) - val associationFailureCause = tlvReader.getUInt(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) + val associationFailureCause = + tlvReader.getUInt(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) val status = tlvReader.getUInt(ContextSpecificTag(TAG_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterAssociationFailureEvent(associationFailureCause, status) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt index e106ddd9b7498d..34b126059fffd2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class WiFiNetworkDiagnosticsClusterConnectionStatusEvent ( - val connectionStatus: UInt) { - override fun toString(): String = buildString { +class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UInt) { + override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") append("}\n") @@ -45,10 +40,13 @@ class WiFiNetworkDiagnosticsClusterConnectionStatusEvent ( companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUInt(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt index 33cb99c03f48a2..9c0875da20a177 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class WiFiNetworkDiagnosticsClusterDisconnectionEvent ( - val reasonCode: UInt) { - override fun toString(): String = buildString { +class WiFiNetworkDiagnosticsClusterDisconnectionEvent(val reasonCode: UInt) { + override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterDisconnectionEvent {\n") append("\treasonCode : $reasonCode\n") append("}\n") @@ -45,10 +40,13 @@ class WiFiNetworkDiagnosticsClusterDisconnectionEvent ( companion object { private const val TAG_REASON_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterDisconnectionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterDisconnectionEvent { tlvReader.enterStructure(tlvTag) val reasonCode = tlvReader.getUInt(ContextSpecificTag(TAG_REASON_CODE)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterDisconnectionEvent(reasonCode) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt index d228ef19fb8e79..ad7257cc39f901 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt @@ -20,19 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlEntryStruct ( - val privilege: UInt, - val authMode: UInt, - val subjects: List?, - val targets: List?, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlEntryStruct( + val privilege: UInt, + val authMode: UInt, + val subjects: List?, + val targets: List?, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlEntryStruct {\n") append("\tprivilege : $privilege\n") append("\tauthMode : $authMode\n") @@ -48,23 +46,23 @@ class AccessControlClusterAccessControlEntryStruct ( put(ContextSpecificTag(TAG_PRIVILEGE), privilege) put(ContextSpecificTag(TAG_AUTH_MODE), authMode) if (subjects != null) { - startArray(ContextSpecificTag(TAG_SUBJECTS)) - for (item in subjects.iterator()) { - put(AnonymousTag, item) + startArray(ContextSpecificTag(TAG_SUBJECTS)) + for (item in subjects.iterator()) { + put(AnonymousTag, item) + } + endArray() + } else { + putNull(ContextSpecificTag(TAG_SUBJECTS)) } - endArray() - } else { - putNull(ContextSpecificTag(TAG_SUBJECTS)) - } if (targets != null) { - startArray(ContextSpecificTag(TAG_TARGETS)) - for (item in targets.iterator()) { - item.toTlv(AnonymousTag, this) + startArray(ContextSpecificTag(TAG_TARGETS)) + for (item in targets.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } else { + putNull(ContextSpecificTag(TAG_TARGETS)) } - endArray() - } else { - putNull(ContextSpecificTag(TAG_TARGETS)) - } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -77,39 +75,47 @@ class AccessControlClusterAccessControlEntryStruct ( private const val TAG_TARGETS = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlEntryStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlEntryStruct { tlvReader.enterStructure(tlvTag) val privilege = tlvReader.getUInt(ContextSpecificTag(TAG_PRIVILEGE)) val authMode = tlvReader.getUInt(ContextSpecificTag(TAG_AUTH_MODE)) - val subjects = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getULong(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) - null - } - val targets = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) - null - } + val subjects = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getULong(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) + null + } + val targets = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryStruct(privilege, authMode, subjects, targets, fabricIndex) + return AccessControlClusterAccessControlEntryStruct( + privilege, + authMode, + subjects, + targets, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt index b41ebafd9de72a..c75c7632f06be3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlExtensionStruct ( - val data: ByteArray, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlExtensionStruct(val data: ByteArray, val fabricIndex: UInt) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlExtensionStruct {\n") append("\tdata : $data\n") append("\tfabricIndex : $fabricIndex\n") @@ -49,11 +43,14 @@ class AccessControlClusterAccessControlExtensionStruct ( private const val TAG_DATA = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlExtensionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlExtensionStruct { tlvReader.enterStructure(tlvTag) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return AccessControlClusterAccessControlExtensionStruct(data, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt index 1eab00f450d8f0..5fb4de109d6c6a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlTargetStruct ( - val cluster: ULong?, - val endpoint: UInt?, - val deviceType: ULong?) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlTargetStruct( + val cluster: ULong?, + val endpoint: UInt?, + val deviceType: ULong? +) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlTargetStruct {\n") append("\tcluster : $cluster\n") append("\tendpoint : $endpoint\n") @@ -42,20 +39,20 @@ class AccessControlClusterAccessControlTargetStruct ( tlvWriter.apply { startStructure(tlvTag) if (cluster != null) { - put(ContextSpecificTag(TAG_CLUSTER), cluster) - } else { - putNull(ContextSpecificTag(TAG_CLUSTER)) - } + put(ContextSpecificTag(TAG_CLUSTER), cluster) + } else { + putNull(ContextSpecificTag(TAG_CLUSTER)) + } if (endpoint != null) { - put(ContextSpecificTag(TAG_ENDPOINT), endpoint) - } else { - putNull(ContextSpecificTag(TAG_ENDPOINT)) - } + put(ContextSpecificTag(TAG_ENDPOINT), endpoint) + } else { + putNull(ContextSpecificTag(TAG_ENDPOINT)) + } if (deviceType != null) { - put(ContextSpecificTag(TAG_DEVICE_TYPE), deviceType) - } else { - putNull(ContextSpecificTag(TAG_DEVICE_TYPE)) - } + put(ContextSpecificTag(TAG_DEVICE_TYPE), deviceType) + } else { + putNull(ContextSpecificTag(TAG_DEVICE_TYPE)) + } endStructure() } } @@ -65,27 +62,30 @@ class AccessControlClusterAccessControlTargetStruct ( private const val TAG_ENDPOINT = 1 private const val TAG_DEVICE_TYPE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlTargetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlTargetStruct { tlvReader.enterStructure(tlvTag) - val cluster = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) - null - } - val endpoint = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) - null - } - val deviceType = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_TYPE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) - null - } - + val cluster = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) + null + } + val endpoint = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) + null + } + val deviceType = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_TYPE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) + null + } + tlvReader.exitContainer() return AccessControlClusterAccessControlTargetStruct(cluster, endpoint, deviceType) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt index 8ae474f8e727db..5d5c21a6906968 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt @@ -17,23 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActionsClusterActionStruct ( - val actionID: UInt, - val name: String, - val type: UInt, - val endpointListID: UInt, - val supportedCommands: UInt, - val state: UInt) { - override fun toString(): String = buildString { +class ActionsClusterActionStruct( + val actionID: UInt, + val name: String, + val type: UInt, + val endpointListID: UInt, + val supportedCommands: UInt, + val state: UInt +) { + override fun toString(): String = buildString { append("ActionsClusterActionStruct {\n") append("\tactionID : $actionID\n") append("\tname : $name\n") @@ -65,7 +62,7 @@ class ActionsClusterActionStruct ( private const val TAG_SUPPORTED_COMMANDS = 4 private const val TAG_STATE = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterActionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterActionStruct { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUInt(ContextSpecificTag(TAG_ACTION_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) @@ -73,10 +70,17 @@ class ActionsClusterActionStruct ( val endpointListID = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val supportedCommands = tlvReader.getUInt(ContextSpecificTag(TAG_SUPPORTED_COMMANDS)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) - + tlvReader.exitContainer() - return ActionsClusterActionStruct(actionID, name, type, endpointListID, supportedCommands, state) + return ActionsClusterActionStruct( + actionID, + name, + type, + endpointListID, + supportedCommands, + state + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt index a8f078a4ba75c6..d5716531a18c99 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt @@ -20,18 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActionsClusterEndpointListStruct ( - val endpointListID: UInt, - val name: String, - val type: UInt, - val endpoints: List) { - override fun toString(): String = buildString { +class ActionsClusterEndpointListStruct( + val endpointListID: UInt, + val name: String, + val type: UInt, + val endpoints: List +) { + override fun toString(): String = buildString { append("ActionsClusterEndpointListStruct {\n") append("\tendpointListID : $endpointListID\n") append("\tname : $name\n") @@ -61,19 +59,20 @@ class ActionsClusterEndpointListStruct ( private const val TAG_TYPE = 2 private const val TAG_ENDPOINTS = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterEndpointListStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterEndpointListStruct { tlvReader.enterStructure(tlvTag) val endpointListID = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) - val endpoints = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val endpoints = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ActionsClusterEndpointListStruct(endpointListID, name, type, endpoints) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt index fa41e784da11de..138571f0342bb8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct ( - val productIdentifierType: UInt, - val productIdentifierValue: String) { - override fun toString(): String = buildString { +class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( + val productIdentifierType: UInt, + val productIdentifierValue: String +) { + override fun toString(): String = buildString { append("ActivatedCarbonFilterMonitoringClusterReplacementProductStruct {\n") append("\tproductIdentifierType : $productIdentifierType\n") append("\tproductIdentifierValue : $productIdentifierValue\n") @@ -49,14 +46,21 @@ class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct ( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) val productIdentifierType = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierValue = + tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) + return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( + productIdentifierType, + productIdentifierValue + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt index f052c51f03c144..1fb108656c7973 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ApplicationBasicClusterApplicationStruct ( - val catalogVendorID: UInt, - val applicationID: String) { - override fun toString(): String = buildString { +class ApplicationBasicClusterApplicationStruct( + val catalogVendorID: UInt, + val applicationID: String +) { + override fun toString(): String = buildString { append("ApplicationBasicClusterApplicationStruct {\n") append("\tcatalogVendorID : $catalogVendorID\n") append("\tapplicationID : $applicationID\n") @@ -49,11 +46,11 @@ class ApplicationBasicClusterApplicationStruct ( private const val TAG_CATALOG_VENDOR_I_D = 0 private const val TAG_APPLICATION_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ApplicationBasicClusterApplicationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationBasicClusterApplicationStruct { tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUInt(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationBasicClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt index 89f372803fe317..ea33f81faaf3e0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ApplicationLauncherClusterApplicationEPStruct ( - val application: ApplicationLauncherClusterApplicationStruct, - val endpoint: Optional) { - override fun toString(): String = buildString { +class ApplicationLauncherClusterApplicationEPStruct( + val application: ApplicationLauncherClusterApplicationStruct, + val endpoint: Optional +) { + override fun toString(): String = buildString { append("ApplicationLauncherClusterApplicationEPStruct {\n") append("\tapplication : $application\n") append("\tendpoint : $endpoint\n") @@ -41,9 +39,9 @@ class ApplicationLauncherClusterApplicationEPStruct ( startStructure(tlvTag) application.toTlv(ContextSpecificTag(TAG_APPLICATION), this) if (endpoint.isPresent) { - val optendpoint = endpoint.get() - put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) - } + val optendpoint = endpoint.get() + put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) + } endStructure() } } @@ -52,15 +50,20 @@ class ApplicationLauncherClusterApplicationEPStruct ( private const val TAG_APPLICATION = 0 private const val TAG_ENDPOINT = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ApplicationLauncherClusterApplicationEPStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationLauncherClusterApplicationEPStruct { tlvReader.enterStructure(tlvTag) - val application = ApplicationLauncherClusterApplicationStruct.fromTlv(ContextSpecificTag(TAG_APPLICATION), tlvReader) - val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - + val application = + ApplicationLauncherClusterApplicationStruct.fromTlv( + ContextSpecificTag(TAG_APPLICATION), + tlvReader + ) + val endpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationEPStruct(application, endpoint) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt index b306cbca62125a..c7ec51b47dfb4b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ApplicationLauncherClusterApplicationStruct ( - val catalogVendorID: UInt, - val applicationID: String) { - override fun toString(): String = buildString { +class ApplicationLauncherClusterApplicationStruct( + val catalogVendorID: UInt, + val applicationID: String +) { + override fun toString(): String = buildString { append("ApplicationLauncherClusterApplicationStruct {\n") append("\tcatalogVendorID : $catalogVendorID\n") append("\tapplicationID : $applicationID\n") @@ -49,11 +46,11 @@ class ApplicationLauncherClusterApplicationStruct ( private const val TAG_CATALOG_VENDOR_I_D = 0 private const val TAG_APPLICATION_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ApplicationLauncherClusterApplicationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationLauncherClusterApplicationStruct { tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUInt(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt index 60726ce82d5c56..6336549e45a0bc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt @@ -17,20 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AudioOutputClusterOutputInfoStruct ( - val index: UInt, - val outputType: UInt, - val name: String) { - override fun toString(): String = buildString { +class AudioOutputClusterOutputInfoStruct(val index: UInt, val outputType: UInt, val name: String) { + override fun toString(): String = buildString { append("AudioOutputClusterOutputInfoStruct {\n") append("\tindex : $index\n") append("\toutputType : $outputType\n") @@ -53,12 +46,12 @@ class AudioOutputClusterOutputInfoStruct ( private const val TAG_OUTPUT_TYPE = 1 private const val TAG_NAME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AudioOutputClusterOutputInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AudioOutputClusterOutputInfoStruct { tlvReader.enterStructure(tlvTag) val index = tlvReader.getUInt(ContextSpecificTag(TAG_INDEX)) val outputType = tlvReader.getUInt(ContextSpecificTag(TAG_OUTPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return AudioOutputClusterOutputInfoStruct(index, outputType, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt index 494c946f40b998..d79225dd61468e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterCapabilityMinimaStruct ( - val caseSessionsPerFabric: UInt, - val subscriptionsPerFabric: UInt) { - override fun toString(): String = buildString { +class BasicInformationClusterCapabilityMinimaStruct( + val caseSessionsPerFabric: UInt, + val subscriptionsPerFabric: UInt +) { + override fun toString(): String = buildString { append("BasicInformationClusterCapabilityMinimaStruct {\n") append("\tcaseSessionsPerFabric : $caseSessionsPerFabric\n") append("\tsubscriptionsPerFabric : $subscriptionsPerFabric\n") @@ -49,14 +46,19 @@ class BasicInformationClusterCapabilityMinimaStruct ( private const val TAG_CASE_SESSIONS_PER_FABRIC = 0 private const val TAG_SUBSCRIPTIONS_PER_FABRIC = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterCapabilityMinimaStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterCapabilityMinimaStruct { tlvReader.enterStructure(tlvTag) - val caseSessionsPerFabric = tlvReader.getUInt(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) - val subscriptionsPerFabric = tlvReader.getUInt(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) - + val caseSessionsPerFabric = + tlvReader.getUInt(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) + val subscriptionsPerFabric = + tlvReader.getUInt(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) + tlvReader.exitContainer() - return BasicInformationClusterCapabilityMinimaStruct(caseSessionsPerFabric, subscriptionsPerFabric) + return BasicInformationClusterCapabilityMinimaStruct( + caseSessionsPerFabric, + subscriptionsPerFabric + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt index 44f42edb6adf2d..5a0eb3ace2ef7b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterProductAppearanceStruct ( - val finish: UInt, - val primaryColor: UInt?) { - override fun toString(): String = buildString { +class BasicInformationClusterProductAppearanceStruct(val finish: UInt, val primaryColor: UInt?) { + override fun toString(): String = buildString { append("BasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") append("\tprimaryColor : $primaryColor\n") @@ -41,10 +35,10 @@ class BasicInformationClusterProductAppearanceStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_FINISH), finish) if (primaryColor != null) { - put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) - } else { - putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } + put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) + } else { + putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } endStructure() } } @@ -53,16 +47,17 @@ class BasicInformationClusterProductAppearanceStruct ( private const val TAG_FINISH = 0 private const val TAG_PRIMARY_COLOR = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterProductAppearanceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUInt(ContextSpecificTag(TAG_FINISH)) - val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt index 9454790cb7ac05..70c8deedaaaf6a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BindingClusterTargetStruct ( - val node: Optional, - val group: Optional, - val endpoint: Optional, - val cluster: Optional, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class BindingClusterTargetStruct( + val node: Optional, + val group: Optional, + val endpoint: Optional, + val cluster: Optional, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("BindingClusterTargetStruct {\n") append("\tnode : $node\n") append("\tgroup : $group\n") @@ -46,21 +44,21 @@ class BindingClusterTargetStruct ( tlvWriter.apply { startStructure(tlvTag) if (node.isPresent) { - val optnode = node.get() - put(ContextSpecificTag(TAG_NODE), optnode) - } + val optnode = node.get() + put(ContextSpecificTag(TAG_NODE), optnode) + } if (group.isPresent) { - val optgroup = group.get() - put(ContextSpecificTag(TAG_GROUP), optgroup) - } + val optgroup = group.get() + put(ContextSpecificTag(TAG_GROUP), optgroup) + } if (endpoint.isPresent) { - val optendpoint = endpoint.get() - put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) - } + val optendpoint = endpoint.get() + put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) + } if (cluster.isPresent) { - val optcluster = cluster.get() - put(ContextSpecificTag(TAG_CLUSTER), optcluster) - } + val optcluster = cluster.get() + put(ContextSpecificTag(TAG_CLUSTER), optcluster) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -73,30 +71,34 @@ class BindingClusterTargetStruct ( private const val TAG_CLUSTER = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BindingClusterTargetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BindingClusterTargetStruct { tlvReader.enterStructure(tlvTag) - val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - val group = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_GROUP))) - } else { - Optional.empty() - } - val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - val cluster = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER))) - } else { - Optional.empty() - } + val node = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + val group = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_GROUP))) + } else { + Optional.empty() + } + val endpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + val cluster = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BindingClusterTargetStruct(node, group, endpoint, cluster, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt index 6f548b1a015b9c..ec2d58aa588cea 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BridgedDeviceBasicInformationClusterProductAppearanceStruct ( - val finish: UInt, - val primaryColor: UInt?) { - override fun toString(): String = buildString { +class BridgedDeviceBasicInformationClusterProductAppearanceStruct( + val finish: UInt, + val primaryColor: UInt? +) { + override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") append("\tprimaryColor : $primaryColor\n") @@ -41,10 +38,10 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_FINISH), finish) if (primaryColor != null) { - put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) - } else { - putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } + put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) + } else { + putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } endStructure() } } @@ -53,16 +50,20 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct ( private const val TAG_FINISH = 0 private const val TAG_PRIMARY_COLOR = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterProductAppearanceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUInt(ContextSpecificTag(TAG_FINISH)) - val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt index 9fe7d172bf4551..082ea9c5debbbc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterAdditionalInfoStruct ( - val name: String, - val value: String) { - override fun toString(): String = buildString { +class ChannelClusterAdditionalInfoStruct(val name: String, val value: String) { + override fun toString(): String = buildString { append("ChannelClusterAdditionalInfoStruct {\n") append("\tname : $name\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class ChannelClusterAdditionalInfoStruct ( private const val TAG_NAME = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterAdditionalInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterAdditionalInfoStruct { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ChannelClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt index a72550236ad007..deb76c4fb0791c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt @@ -17,24 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterChannelInfoStruct ( - val majorNumber: UInt, - val minorNumber: UInt, - val name: Optional, - val callSign: Optional, - val affiliateCallSign: Optional, - val identifier: Optional, - val type: Optional) { - override fun toString(): String = buildString { +class ChannelClusterChannelInfoStruct( + val majorNumber: UInt, + val minorNumber: UInt, + val name: Optional, + val callSign: Optional, + val affiliateCallSign: Optional, + val identifier: Optional, + val type: Optional +) { + override fun toString(): String = buildString { append("ChannelClusterChannelInfoStruct {\n") append("\tmajorNumber : $majorNumber\n") append("\tminorNumber : $minorNumber\n") @@ -52,25 +50,25 @@ class ChannelClusterChannelInfoStruct ( put(ContextSpecificTag(TAG_MAJOR_NUMBER), majorNumber) put(ContextSpecificTag(TAG_MINOR_NUMBER), minorNumber) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (callSign.isPresent) { - val optcallSign = callSign.get() - put(ContextSpecificTag(TAG_CALL_SIGN), optcallSign) - } + val optcallSign = callSign.get() + put(ContextSpecificTag(TAG_CALL_SIGN), optcallSign) + } if (affiliateCallSign.isPresent) { - val optaffiliateCallSign = affiliateCallSign.get() - put(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN), optaffiliateCallSign) - } + val optaffiliateCallSign = affiliateCallSign.get() + put(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN), optaffiliateCallSign) + } if (identifier.isPresent) { - val optidentifier = identifier.get() - put(ContextSpecificTag(TAG_IDENTIFIER), optidentifier) - } + val optidentifier = identifier.get() + put(ContextSpecificTag(TAG_IDENTIFIER), optidentifier) + } if (type.isPresent) { - val opttype = type.get() - put(ContextSpecificTag(TAG_TYPE), opttype) - } + val opttype = type.get() + put(ContextSpecificTag(TAG_TYPE), opttype) + } endStructure() } } @@ -84,39 +82,52 @@ class ChannelClusterChannelInfoStruct ( private const val TAG_IDENTIFIER = 5 private const val TAG_TYPE = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterChannelInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterChannelInfoStruct { tlvReader.enterStructure(tlvTag) val majorNumber = tlvReader.getUInt(ContextSpecificTag(TAG_MAJOR_NUMBER)) val minorNumber = tlvReader.getUInt(ContextSpecificTag(TAG_MINOR_NUMBER)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val callSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) - } else { - Optional.empty() - } - val affiliateCallSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) - } else { - Optional.empty() - } - val identifier = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) - } else { - Optional.empty() - } - val type = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TYPE))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val callSign = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) + } else { + Optional.empty() + } + val affiliateCallSign = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) + } else { + Optional.empty() + } + val identifier = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) + } else { + Optional.empty() + } + val type = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TYPE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterChannelInfoStruct(majorNumber, minorNumber, name, callSign, affiliateCallSign, identifier, type) + return ChannelClusterChannelInfoStruct( + majorNumber, + minorNumber, + name, + callSign, + affiliateCallSign, + identifier, + type + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt index 936bdfd02a603b..64b035d2b02583 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterChannelPagingStruct ( - val previousToken: Optional?, - val nextToken: Optional?) { - override fun toString(): String = buildString { +class ChannelClusterChannelPagingStruct( + val previousToken: Optional?, + val nextToken: Optional? +) { + override fun toString(): String = buildString { append("ChannelClusterChannelPagingStruct {\n") append("\tpreviousToken : $previousToken\n") append("\tnextToken : $nextToken\n") @@ -40,21 +38,21 @@ class ChannelClusterChannelPagingStruct ( tlvWriter.apply { startStructure(tlvTag) if (previousToken != null) { - if (previousToken.isPresent) { - val optpreviousToken = previousToken.get() - optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) - } - } else { - putNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) - } + if (previousToken.isPresent) { + val optpreviousToken = previousToken.get() + optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) + } + } else { + putNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) + } if (nextToken != null) { - if (nextToken.isPresent) { - val optnextToken = nextToken.get() - optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) - } - } else { - putNull(ContextSpecificTag(TAG_NEXT_TOKEN)) - } + if (nextToken.isPresent) { + val optnextToken = nextToken.get() + optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) + } + } else { + putNull(ContextSpecificTag(TAG_NEXT_TOKEN)) + } endStructure() } } @@ -63,29 +61,38 @@ class ChannelClusterChannelPagingStruct ( private const val TAG_PREVIOUS_TOKEN = 0 private const val TAG_NEXT_TOKEN = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterChannelPagingStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterChannelPagingStruct { tlvReader.enterStructure(tlvTag) - val previousToken = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { - Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) - null - } - val nextToken = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { - Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) - null - } - + val previousToken = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { + Optional.of( + ChannelClusterPageTokenStruct.fromTlv( + ContextSpecificTag(TAG_PREVIOUS_TOKEN), + tlvReader + ) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) + null + } + val nextToken = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { + Optional.of( + ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) + null + } + tlvReader.exitContainer() return ChannelClusterChannelPagingStruct(previousToken, nextToken) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt index 357509b7e3eb70..d205e89f966bae 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterLineupInfoStruct ( - val operatorName: String, - val lineupName: Optional, - val postalCode: Optional, - val lineupInfoType: UInt) { - override fun toString(): String = buildString { +class ChannelClusterLineupInfoStruct( + val operatorName: String, + val lineupName: Optional, + val postalCode: Optional, + val lineupInfoType: UInt +) { + override fun toString(): String = buildString { append("ChannelClusterLineupInfoStruct {\n") append("\toperatorName : $operatorName\n") append("\tlineupName : $lineupName\n") @@ -45,13 +43,13 @@ class ChannelClusterLineupInfoStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATOR_NAME), operatorName) if (lineupName.isPresent) { - val optlineupName = lineupName.get() - put(ContextSpecificTag(TAG_LINEUP_NAME), optlineupName) - } + val optlineupName = lineupName.get() + put(ContextSpecificTag(TAG_LINEUP_NAME), optlineupName) + } if (postalCode.isPresent) { - val optpostalCode = postalCode.get() - put(ContextSpecificTag(TAG_POSTAL_CODE), optpostalCode) - } + val optpostalCode = postalCode.get() + put(ContextSpecificTag(TAG_POSTAL_CODE), optpostalCode) + } put(ContextSpecificTag(TAG_LINEUP_INFO_TYPE), lineupInfoType) endStructure() } @@ -63,21 +61,23 @@ class ChannelClusterLineupInfoStruct ( private const val TAG_POSTAL_CODE = 2 private const val TAG_LINEUP_INFO_TYPE = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterLineupInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterLineupInfoStruct { tlvReader.enterStructure(tlvTag) val operatorName = tlvReader.getString(ContextSpecificTag(TAG_OPERATOR_NAME)) - val lineupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) - } else { - Optional.empty() - } - val postalCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) - } else { - Optional.empty() - } + val lineupName = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) + } else { + Optional.empty() + } + val postalCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) + } else { + Optional.empty() + } val lineupInfoType = tlvReader.getUInt(ContextSpecificTag(TAG_LINEUP_INFO_TYPE)) - + tlvReader.exitContainer() return ChannelClusterLineupInfoStruct(operatorName, lineupName, postalCode, lineupInfoType) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt index 73639a9681a7b3..18e92f157a24d4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterPageTokenStruct ( - val limit: Optional, - val after: Optional, - val before: Optional) { - override fun toString(): String = buildString { +class ChannelClusterPageTokenStruct( + val limit: Optional, + val after: Optional, + val before: Optional +) { + override fun toString(): String = buildString { append("ChannelClusterPageTokenStruct {\n") append("\tlimit : $limit\n") append("\tafter : $after\n") @@ -42,17 +40,17 @@ class ChannelClusterPageTokenStruct ( tlvWriter.apply { startStructure(tlvTag) if (limit.isPresent) { - val optlimit = limit.get() - put(ContextSpecificTag(TAG_LIMIT), optlimit) - } + val optlimit = limit.get() + put(ContextSpecificTag(TAG_LIMIT), optlimit) + } if (after.isPresent) { - val optafter = after.get() - put(ContextSpecificTag(TAG_AFTER), optafter) - } + val optafter = after.get() + put(ContextSpecificTag(TAG_AFTER), optafter) + } if (before.isPresent) { - val optbefore = before.get() - put(ContextSpecificTag(TAG_BEFORE), optbefore) - } + val optbefore = before.get() + put(ContextSpecificTag(TAG_BEFORE), optbefore) + } endStructure() } } @@ -62,24 +60,27 @@ class ChannelClusterPageTokenStruct ( private const val TAG_AFTER = 1 private const val TAG_BEFORE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterPageTokenStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterPageTokenStruct { tlvReader.enterStructure(tlvTag) - val limit = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LIMIT))) - } else { - Optional.empty() - } - val after = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) - } else { - Optional.empty() - } - val before = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) - } else { - Optional.empty() - } - + val limit = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LIMIT))) + } else { + Optional.empty() + } + val after = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) + } else { + Optional.empty() + } + val before = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterPageTokenStruct(limit, after, before) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt index 5d03551b82d852..b11edabf62f0b0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterProgramCastStruct ( - val name: String, - val role: String) { - override fun toString(): String = buildString { +class ChannelClusterProgramCastStruct(val name: String, val role: String) { + override fun toString(): String = buildString { append("ChannelClusterProgramCastStruct {\n") append("\tname : $name\n") append("\trole : $role\n") @@ -49,11 +43,11 @@ class ChannelClusterProgramCastStruct ( private const val TAG_NAME = 0 private const val TAG_ROLE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterProgramCastStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramCastStruct { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val role = tlvReader.getString(ContextSpecificTag(TAG_ROLE)) - + tlvReader.exitContainer() return ChannelClusterProgramCastStruct(name, role) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt index 66800400ce15bb..d22742f8be42c5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterProgramCategoryStruct ( - val category: String, - val subCategory: Optional) { - override fun toString(): String = buildString { +class ChannelClusterProgramCategoryStruct(val category: String, val subCategory: Optional) { + override fun toString(): String = buildString { append("ChannelClusterProgramCategoryStruct {\n") append("\tcategory : $category\n") append("\tsubCategory : $subCategory\n") @@ -41,9 +36,9 @@ class ChannelClusterProgramCategoryStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_CATEGORY), category) if (subCategory.isPresent) { - val optsubCategory = subCategory.get() - put(ContextSpecificTag(TAG_SUB_CATEGORY), optsubCategory) - } + val optsubCategory = subCategory.get() + put(ContextSpecificTag(TAG_SUB_CATEGORY), optsubCategory) + } endStructure() } } @@ -52,15 +47,16 @@ class ChannelClusterProgramCategoryStruct ( private const val TAG_CATEGORY = 0 private const val TAG_SUB_CATEGORY = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterProgramCategoryStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramCategoryStruct { tlvReader.enterStructure(tlvTag) val category = tlvReader.getString(ContextSpecificTag(TAG_CATEGORY)) - val subCategory = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) - } else { - Optional.empty() - } - + val subCategory = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterProgramCategoryStruct(category, subCategory) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt index 82c4ab33b445ed..5f5a7e48d1b8dc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt @@ -17,36 +17,35 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterProgramStruct ( - val identifier: String, - val channel: ChannelClusterChannelInfoStruct, - val startTime: ULong, - val endTime: ULong, - val title: String, - val subtitle: Optional, - val description: Optional, - val audioLanguages: Optional>, - val ratings: Optional>, - val thumbnailUrl: Optional, - val posterArtUrl: Optional, - val dvbiUrl: Optional, - val releaseDate: Optional, - val parentalGuidanceText: Optional, - val recordingFlag: Optional, - val seriesInfo: Optional?, - val categoryList: Optional>, - val castList: Optional>, - val externalIDList: Optional>) { - override fun toString(): String = buildString { +class ChannelClusterProgramStruct( + val identifier: String, + val channel: ChannelClusterChannelInfoStruct, + val startTime: ULong, + val endTime: ULong, + val title: String, + val subtitle: Optional, + val description: Optional, + val audioLanguages: Optional>, + val ratings: Optional>, + val thumbnailUrl: Optional, + val posterArtUrl: Optional, + val dvbiUrl: Optional, + val releaseDate: Optional, + val parentalGuidanceText: Optional, + val recordingFlag: Optional, + val seriesInfo: Optional?, + val categoryList: Optional>, + val castList: Optional>, + val externalIDList: Optional> +) { + override fun toString(): String = buildString { append("ChannelClusterProgramStruct {\n") append("\tidentifier : $identifier\n") append("\tchannel : $channel\n") @@ -79,85 +78,85 @@ class ChannelClusterProgramStruct ( put(ContextSpecificTag(TAG_END_TIME), endTime) put(ContextSpecificTag(TAG_TITLE), title) if (subtitle.isPresent) { - val optsubtitle = subtitle.get() - put(ContextSpecificTag(TAG_SUBTITLE), optsubtitle) - } + val optsubtitle = subtitle.get() + put(ContextSpecificTag(TAG_SUBTITLE), optsubtitle) + } if (description.isPresent) { - val optdescription = description.get() - put(ContextSpecificTag(TAG_DESCRIPTION), optdescription) - } + val optdescription = description.get() + put(ContextSpecificTag(TAG_DESCRIPTION), optdescription) + } if (audioLanguages.isPresent) { - val optaudioLanguages = audioLanguages.get() - startArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - for (item in optaudioLanguages.iterator()) { - put(AnonymousTag, item) + val optaudioLanguages = audioLanguages.get() + startArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) + for (item in optaudioLanguages.iterator()) { + put(AnonymousTag, item) + } + endArray() } - endArray() - } if (ratings.isPresent) { - val optratings = ratings.get() - startArray(ContextSpecificTag(TAG_RATINGS)) - for (item in optratings.iterator()) { - put(AnonymousTag, item) + val optratings = ratings.get() + startArray(ContextSpecificTag(TAG_RATINGS)) + for (item in optratings.iterator()) { + put(AnonymousTag, item) + } + endArray() } - endArray() - } if (thumbnailUrl.isPresent) { - val optthumbnailUrl = thumbnailUrl.get() - put(ContextSpecificTag(TAG_THUMBNAIL_URL), optthumbnailUrl) - } + val optthumbnailUrl = thumbnailUrl.get() + put(ContextSpecificTag(TAG_THUMBNAIL_URL), optthumbnailUrl) + } if (posterArtUrl.isPresent) { - val optposterArtUrl = posterArtUrl.get() - put(ContextSpecificTag(TAG_POSTER_ART_URL), optposterArtUrl) - } + val optposterArtUrl = posterArtUrl.get() + put(ContextSpecificTag(TAG_POSTER_ART_URL), optposterArtUrl) + } if (dvbiUrl.isPresent) { - val optdvbiUrl = dvbiUrl.get() - put(ContextSpecificTag(TAG_DVBI_URL), optdvbiUrl) - } + val optdvbiUrl = dvbiUrl.get() + put(ContextSpecificTag(TAG_DVBI_URL), optdvbiUrl) + } if (releaseDate.isPresent) { - val optreleaseDate = releaseDate.get() - put(ContextSpecificTag(TAG_RELEASE_DATE), optreleaseDate) - } + val optreleaseDate = releaseDate.get() + put(ContextSpecificTag(TAG_RELEASE_DATE), optreleaseDate) + } if (parentalGuidanceText.isPresent) { - val optparentalGuidanceText = parentalGuidanceText.get() - put(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT), optparentalGuidanceText) - } + val optparentalGuidanceText = parentalGuidanceText.get() + put(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT), optparentalGuidanceText) + } if (recordingFlag.isPresent) { - val optrecordingFlag = recordingFlag.get() - put(ContextSpecificTag(TAG_RECORDING_FLAG), optrecordingFlag) - } + val optrecordingFlag = recordingFlag.get() + put(ContextSpecificTag(TAG_RECORDING_FLAG), optrecordingFlag) + } if (seriesInfo != null) { - if (seriesInfo.isPresent) { - val optseriesInfo = seriesInfo.get() - optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) - } - } else { - putNull(ContextSpecificTag(TAG_SERIES_INFO)) - } + if (seriesInfo.isPresent) { + val optseriesInfo = seriesInfo.get() + optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) + } + } else { + putNull(ContextSpecificTag(TAG_SERIES_INFO)) + } if (categoryList.isPresent) { - val optcategoryList = categoryList.get() - startArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - for (item in optcategoryList.iterator()) { - item.toTlv(AnonymousTag, this) + val optcategoryList = categoryList.get() + startArray(ContextSpecificTag(TAG_CATEGORY_LIST)) + for (item in optcategoryList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } if (castList.isPresent) { - val optcastList = castList.get() - startArray(ContextSpecificTag(TAG_CAST_LIST)) - for (item in optcastList.iterator()) { - item.toTlv(AnonymousTag, this) + val optcastList = castList.get() + startArray(ContextSpecificTag(TAG_CAST_LIST)) + for (item in optcastList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } if (externalIDList.isPresent) { - val optexternalIDList = externalIDList.get() - startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) + val optexternalIDList = externalIDList.get() + startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } endStructure() } } @@ -183,122 +182,169 @@ class ChannelClusterProgramStruct ( private const val TAG_CAST_LIST = 17 private const val TAG_EXTERNAL_I_D_LIST = 18 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterProgramStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramStruct { tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER)) - val channel = ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) + val channel = + ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getULong(ContextSpecificTag(TAG_END_TIME)) val title = tlvReader.getString(ContextSpecificTag(TAG_TITLE)) - val subtitle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) - } else { - Optional.empty() - } - val description = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) - } else { - Optional.empty() - } - val audioLanguages = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val ratings = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val thumbnailUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) - } else { - Optional.empty() - } - val posterArtUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) - } else { - Optional.empty() - } - val dvbiUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) - } else { - Optional.empty() - } - val releaseDate = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) - } else { - Optional.empty() - } - val parentalGuidanceText = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) - } else { - Optional.empty() - } - val recordingFlag = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RECORDING_FLAG))) - } else { - Optional.empty() - } - val seriesInfo = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { - Optional.of(ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) - null - } - val categoryList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val castList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val subtitle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) + } else { + Optional.empty() + } + val description = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) + } else { + Optional.empty() + } + val audioLanguages = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val ratings = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val thumbnailUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) + } else { + Optional.empty() + } + val posterArtUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) + } else { + Optional.empty() + } + val dvbiUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) + } else { + Optional.empty() + } + val releaseDate = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) + } else { + Optional.empty() + } + val parentalGuidanceText = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) + } else { + Optional.empty() + } + val recordingFlag = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RECORDING_FLAG))) + } else { + Optional.empty() + } + val seriesInfo = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { + Optional.of( + ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) + null + } + val categoryList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val castList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val externalIDList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterProgramStruct(identifier, channel, startTime, endTime, title, subtitle, description, audioLanguages, ratings, thumbnailUrl, posterArtUrl, dvbiUrl, releaseDate, parentalGuidanceText, recordingFlag, seriesInfo, categoryList, castList, externalIDList) + return ChannelClusterProgramStruct( + identifier, + channel, + startTime, + endTime, + title, + subtitle, + description, + audioLanguages, + ratings, + thumbnailUrl, + posterArtUrl, + dvbiUrl, + releaseDate, + parentalGuidanceText, + recordingFlag, + seriesInfo, + categoryList, + castList, + externalIDList + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt index 93e49be4ae9eb0..eb06e3fe6dac2a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterSeriesInfoStruct ( - val season: String, - val episode: String) { - override fun toString(): String = buildString { +class ChannelClusterSeriesInfoStruct(val season: String, val episode: String) { + override fun toString(): String = buildString { append("ChannelClusterSeriesInfoStruct {\n") append("\tseason : $season\n") append("\tepisode : $episode\n") @@ -49,11 +43,11 @@ class ChannelClusterSeriesInfoStruct ( private const val TAG_SEASON = 0 private const val TAG_EPISODE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterSeriesInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterSeriesInfoStruct { tlvReader.enterStructure(tlvTag) val season = tlvReader.getString(ContextSpecificTag(TAG_SEASON)) val episode = tlvReader.getString(ContextSpecificTag(TAG_EPISODE)) - + tlvReader.exitContainer() return ChannelClusterSeriesInfoStruct(season, episode) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt index c1aab30b53c51f..c22158cb36c3bd 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentControlClusterRatingNameStruct ( - val ratingName: String, - val ratingNameDesc: Optional) { - override fun toString(): String = buildString { +class ContentControlClusterRatingNameStruct( + val ratingName: String, + val ratingNameDesc: Optional +) { + override fun toString(): String = buildString { append("ContentControlClusterRatingNameStruct {\n") append("\tratingName : $ratingName\n") append("\tratingNameDesc : $ratingNameDesc\n") @@ -41,9 +39,9 @@ class ContentControlClusterRatingNameStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_RATING_NAME), ratingName) if (ratingNameDesc.isPresent) { - val optratingNameDesc = ratingNameDesc.get() - put(ContextSpecificTag(TAG_RATING_NAME_DESC), optratingNameDesc) - } + val optratingNameDesc = ratingNameDesc.get() + put(ContextSpecificTag(TAG_RATING_NAME_DESC), optratingNameDesc) + } endStructure() } } @@ -52,15 +50,16 @@ class ContentControlClusterRatingNameStruct ( private const val TAG_RATING_NAME = 0 private const val TAG_RATING_NAME_DESC = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentControlClusterRatingNameStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentControlClusterRatingNameStruct { tlvReader.enterStructure(tlvTag) val ratingName = tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME)) - val ratingNameDesc = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) - } else { - Optional.empty() - } - + val ratingNameDesc = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentControlClusterRatingNameStruct(ratingName, ratingNameDesc) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt index cdc41e36467d57..c9df652a2ca5a8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterAdditionalInfoStruct ( - val name: String, - val value: String) { - override fun toString(): String = buildString { +class ContentLauncherClusterAdditionalInfoStruct(val name: String, val value: String) { + override fun toString(): String = buildString { append("ContentLauncherClusterAdditionalInfoStruct {\n") append("\tname : $name\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class ContentLauncherClusterAdditionalInfoStruct ( private const val TAG_NAME = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterAdditionalInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterAdditionalInfoStruct { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ContentLauncherClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt index 56028fc4d11e93..5508763757c036 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt @@ -17,23 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterBrandingInformationStruct ( - val providerName: String, - val background: Optional, - val logo: Optional, - val progressBar: Optional, - val splash: Optional, - val waterMark: Optional) { - override fun toString(): String = buildString { +class ContentLauncherClusterBrandingInformationStruct( + val providerName: String, + val background: Optional, + val logo: Optional, + val progressBar: Optional, + val splash: Optional, + val waterMark: Optional +) { + override fun toString(): String = buildString { append("ContentLauncherClusterBrandingInformationStruct {\n") append("\tproviderName : $providerName\n") append("\tbackground : $background\n") @@ -49,25 +47,25 @@ class ContentLauncherClusterBrandingInformationStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_PROVIDER_NAME), providerName) if (background.isPresent) { - val optbackground = background.get() - optbackground.toTlv(ContextSpecificTag(TAG_BACKGROUND), this) - } + val optbackground = background.get() + optbackground.toTlv(ContextSpecificTag(TAG_BACKGROUND), this) + } if (logo.isPresent) { - val optlogo = logo.get() - optlogo.toTlv(ContextSpecificTag(TAG_LOGO), this) - } + val optlogo = logo.get() + optlogo.toTlv(ContextSpecificTag(TAG_LOGO), this) + } if (progressBar.isPresent) { - val optprogressBar = progressBar.get() - optprogressBar.toTlv(ContextSpecificTag(TAG_PROGRESS_BAR), this) - } + val optprogressBar = progressBar.get() + optprogressBar.toTlv(ContextSpecificTag(TAG_PROGRESS_BAR), this) + } if (splash.isPresent) { - val optsplash = splash.get() - optsplash.toTlv(ContextSpecificTag(TAG_SPLASH), this) - } + val optsplash = splash.get() + optsplash.toTlv(ContextSpecificTag(TAG_SPLASH), this) + } if (waterMark.isPresent) { - val optwaterMark = waterMark.get() - optwaterMark.toTlv(ContextSpecificTag(TAG_WATER_MARK), this) - } + val optwaterMark = waterMark.get() + optwaterMark.toTlv(ContextSpecificTag(TAG_WATER_MARK), this) + } endStructure() } } @@ -80,38 +78,78 @@ class ContentLauncherClusterBrandingInformationStruct ( private const val TAG_SPLASH = 4 private const val TAG_WATER_MARK = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterBrandingInformationStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ContentLauncherClusterBrandingInformationStruct { tlvReader.enterStructure(tlvTag) val providerName = tlvReader.getString(ContextSpecificTag(TAG_PROVIDER_NAME)) - val background = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_BACKGROUND), tlvReader)) - } else { - Optional.empty() - } - val logo = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_LOGO), tlvReader)) - } else { - Optional.empty() - } - val progressBar = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_PROGRESS_BAR), tlvReader)) - } else { - Optional.empty() - } - val splash = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_SPLASH), tlvReader)) - } else { - Optional.empty() - } - val waterMark = if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_WATER_MARK), tlvReader)) - } else { - Optional.empty() - } - + val background = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_BACKGROUND), + tlvReader + ) + ) + } else { + Optional.empty() + } + val logo = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_LOGO), + tlvReader + ) + ) + } else { + Optional.empty() + } + val progressBar = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_PROGRESS_BAR), + tlvReader + ) + ) + } else { + Optional.empty() + } + val splash = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_SPLASH), + tlvReader + ) + ) + } else { + Optional.empty() + } + val waterMark = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_WATER_MARK), + tlvReader + ) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterBrandingInformationStruct(providerName, background, logo, progressBar, splash, waterMark) + return ContentLauncherClusterBrandingInformationStruct( + providerName, + background, + logo, + progressBar, + splash, + waterMark + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt index 9f100e058c4305..fc1cfc5de7b014 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt @@ -20,15 +20,13 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterContentSearchStruct ( - val parameterList: List) { - override fun toString(): String = buildString { +class ContentLauncherClusterContentSearchStruct( + val parameterList: List +) { + override fun toString(): String = buildString { append("ContentLauncherClusterContentSearchStruct {\n") append("\tparameterList : $parameterList\n") append("}\n") @@ -49,16 +47,17 @@ class ContentLauncherClusterContentSearchStruct ( companion object { private const val TAG_PARAMETER_LIST = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterContentSearchStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterContentSearchStruct { tlvReader.enterStructure(tlvTag) - val parameterList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val parameterList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ContentLauncherClusterContentSearchStruct(parameterList) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt index 8c6fd83e614072..f00027d639958c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterDimensionStruct ( - val width: Double, - val height: Double, - val metric: UInt) { - override fun toString(): String = buildString { +class ContentLauncherClusterDimensionStruct( + val width: Double, + val height: Double, + val metric: UInt +) { + override fun toString(): String = buildString { append("ContentLauncherClusterDimensionStruct {\n") append("\twidth : $width\n") append("\theight : $height\n") @@ -53,12 +50,12 @@ class ContentLauncherClusterDimensionStruct ( private const val TAG_HEIGHT = 1 private const val TAG_METRIC = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterDimensionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterDimensionStruct { tlvReader.enterStructure(tlvTag) val width = tlvReader.getDouble(ContextSpecificTag(TAG_WIDTH)) val height = tlvReader.getDouble(ContextSpecificTag(TAG_HEIGHT)) val metric = tlvReader.getUInt(ContextSpecificTag(TAG_METRIC)) - + tlvReader.exitContainer() return ContentLauncherClusterDimensionStruct(width, height, metric) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt index 0a547a665e8609..458fb5e7b29d9c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt @@ -17,20 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterParameterStruct ( - val type: UInt, - val value: String, - val externalIDList: Optional>) { - override fun toString(): String = buildString { +class ContentLauncherClusterParameterStruct( + val type: UInt, + val value: String, + val externalIDList: Optional> +) { + override fun toString(): String = buildString { append("ContentLauncherClusterParameterStruct {\n") append("\ttype : $type\n") append("\tvalue : $value\n") @@ -44,13 +43,13 @@ class ContentLauncherClusterParameterStruct ( put(ContextSpecificTag(TAG_TYPE), type) put(ContextSpecificTag(TAG_VALUE), value) if (externalIDList.isPresent) { - val optexternalIDList = externalIDList.get() - startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) + val optexternalIDList = externalIDList.get() + startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } endStructure() } } @@ -60,22 +59,25 @@ class ContentLauncherClusterParameterStruct ( private const val TAG_VALUE = 1 private const val TAG_EXTERNAL_I_D_LIST = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterParameterStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterParameterStruct { tlvReader.enterStructure(tlvTag) val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val externalIDList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterParameterStruct(type, value, externalIDList) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt index 6ca30cceaac011..4199602517911f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt @@ -17,20 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterPlaybackPreferencesStruct ( - val playbackPosition: ULong, - val textTrack: ContentLauncherClusterTrackPreferenceStruct, - val audioTracks: Optional>) { - override fun toString(): String = buildString { +class ContentLauncherClusterPlaybackPreferencesStruct( + val playbackPosition: ULong, + val textTrack: ContentLauncherClusterTrackPreferenceStruct, + val audioTracks: Optional> +) { + override fun toString(): String = buildString { append("ContentLauncherClusterPlaybackPreferencesStruct {\n") append("\tplaybackPosition : $playbackPosition\n") append("\ttextTrack : $textTrack\n") @@ -44,13 +43,13 @@ class ContentLauncherClusterPlaybackPreferencesStruct ( put(ContextSpecificTag(TAG_PLAYBACK_POSITION), playbackPosition) textTrack.toTlv(ContextSpecificTag(TAG_TEXT_TRACK), this) if (audioTracks.isPresent) { - val optaudioTracks = audioTracks.get() - startArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - for (item in optaudioTracks.iterator()) { - item.toTlv(AnonymousTag, this) + val optaudioTracks = audioTracks.get() + startArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) + for (item in optaudioTracks.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } endStructure() } } @@ -60,25 +59,39 @@ class ContentLauncherClusterPlaybackPreferencesStruct ( private const val TAG_TEXT_TRACK = 1 private const val TAG_AUDIO_TRACKS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterPlaybackPreferencesStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ContentLauncherClusterPlaybackPreferencesStruct { tlvReader.enterStructure(tlvTag) val playbackPosition = tlvReader.getULong(ContextSpecificTag(TAG_PLAYBACK_POSITION)) - val textTrack = ContentLauncherClusterTrackPreferenceStruct.fromTlv(ContextSpecificTag(TAG_TEXT_TRACK), tlvReader) - val audioTracks = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val textTrack = + ContentLauncherClusterTrackPreferenceStruct.fromTlv( + ContextSpecificTag(TAG_TEXT_TRACK), + tlvReader + ) + val audioTracks = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterPlaybackPreferencesStruct(playbackPosition, textTrack, audioTracks) + return ContentLauncherClusterPlaybackPreferencesStruct( + playbackPosition, + textTrack, + audioTracks + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt index c5de0e5706eaea..9b34f59f3eefa6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterStyleInformationStruct ( - val imageURL: Optional, - val color: Optional, - val size: Optional) { - override fun toString(): String = buildString { +class ContentLauncherClusterStyleInformationStruct( + val imageURL: Optional, + val color: Optional, + val size: Optional +) { + override fun toString(): String = buildString { append("ContentLauncherClusterStyleInformationStruct {\n") append("\timageURL : $imageURL\n") append("\tcolor : $color\n") @@ -42,17 +40,17 @@ class ContentLauncherClusterStyleInformationStruct ( tlvWriter.apply { startStructure(tlvTag) if (imageURL.isPresent) { - val optimageURL = imageURL.get() - put(ContextSpecificTag(TAG_IMAGE_U_R_L), optimageURL) - } + val optimageURL = imageURL.get() + put(ContextSpecificTag(TAG_IMAGE_U_R_L), optimageURL) + } if (color.isPresent) { - val optcolor = color.get() - put(ContextSpecificTag(TAG_COLOR), optcolor) - } + val optcolor = color.get() + put(ContextSpecificTag(TAG_COLOR), optcolor) + } if (size.isPresent) { - val optsize = size.get() - optsize.toTlv(ContextSpecificTag(TAG_SIZE), this) - } + val optsize = size.get() + optsize.toTlv(ContextSpecificTag(TAG_SIZE), this) + } endStructure() } } @@ -62,24 +60,29 @@ class ContentLauncherClusterStyleInformationStruct ( private const val TAG_COLOR = 1 private const val TAG_SIZE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterStyleInformationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterStyleInformationStruct { tlvReader.enterStructure(tlvTag) - val imageURL = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) - } else { - Optional.empty() - } - val color = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) - } else { - Optional.empty() - } - val size = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { - Optional.of(ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader)) - } else { - Optional.empty() - } - + val imageURL = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) + } else { + Optional.empty() + } + val color = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) + } else { + Optional.empty() + } + val size = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { + Optional.of( + ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterStyleInformationStruct(imageURL, color, size) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt index a1f60ee83fe421..d5a3e09a859f73 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt @@ -17,20 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterTrackPreferenceStruct ( - val languageCode: String, - val characteristics: Optional>, - val audioOutputIndex: UInt) { - override fun toString(): String = buildString { +class ContentLauncherClusterTrackPreferenceStruct( + val languageCode: String, + val characteristics: Optional>, + val audioOutputIndex: UInt +) { + override fun toString(): String = buildString { append("ContentLauncherClusterTrackPreferenceStruct {\n") append("\tlanguageCode : $languageCode\n") append("\tcharacteristics : $characteristics\n") @@ -43,13 +42,13 @@ class ContentLauncherClusterTrackPreferenceStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_LANGUAGE_CODE), languageCode) if (characteristics.isPresent) { - val optcharacteristics = characteristics.get() - startArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - for (item in optcharacteristics.iterator()) { - put(AnonymousTag, item) + val optcharacteristics = characteristics.get() + startArray(ContextSpecificTag(TAG_CHARACTERISTICS)) + for (item in optcharacteristics.iterator()) { + put(AnonymousTag, item) + } + endArray() } - endArray() - } put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX), audioOutputIndex) endStructure() } @@ -60,25 +59,32 @@ class ContentLauncherClusterTrackPreferenceStruct ( private const val TAG_CHARACTERISTICS = 1 private const val TAG_AUDIO_OUTPUT_INDEX = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterTrackPreferenceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterTrackPreferenceStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val characteristics = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } + val characteristics = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } val audioOutputIndex = tlvReader.getUInt(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX)) - + tlvReader.exitContainer() - return ContentLauncherClusterTrackPreferenceStruct(languageCode, characteristics, audioOutputIndex) + return ContentLauncherClusterTrackPreferenceStruct( + languageCode, + characteristics, + audioOutputIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt index 4357cf625ca244..a4dd7c659efb22 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterAverageLoadControlStruct ( - val loadAdjustment: Int) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterAverageLoadControlStruct(val loadAdjustment: Int) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterAverageLoadControlStruct {\n") append("\tloadAdjustment : $loadAdjustment\n") append("}\n") @@ -45,10 +40,13 @@ class DemandResponseLoadControlClusterAverageLoadControlStruct ( companion object { private const val TAG_LOAD_ADJUSTMENT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterAverageLoadControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterAverageLoadControlStruct { tlvReader.enterStructure(tlvTag) val loadAdjustment = tlvReader.getInt(ContextSpecificTag(TAG_LOAD_ADJUSTMENT)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterAverageLoadControlStruct(loadAdjustment) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt index ce5980bf12eab7..af1ad8026cc11b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterDutyCycleControlStruct ( - val dutyCycle: UInt) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterDutyCycleControlStruct(val dutyCycle: UInt) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterDutyCycleControlStruct {\n") append("\tdutyCycle : $dutyCycle\n") append("}\n") @@ -45,10 +40,13 @@ class DemandResponseLoadControlClusterDutyCycleControlStruct ( companion object { private const val TAG_DUTY_CYCLE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterDutyCycleControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterDutyCycleControlStruct { tlvReader.enterStructure(tlvTag) val dutyCycle = tlvReader.getUInt(ContextSpecificTag(TAG_DUTY_CYCLE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterDutyCycleControlStruct(dutyCycle) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt index c957612bd8942e..049c061b9966e1 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterHeatingSourceControlStruct ( - val heatingSource: UInt) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSource: UInt) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterHeatingSourceControlStruct {\n") append("\theatingSource : $heatingSource\n") append("}\n") @@ -45,10 +40,13 @@ class DemandResponseLoadControlClusterHeatingSourceControlStruct ( companion object { private const val TAG_HEATING_SOURCE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterHeatingSourceControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterHeatingSourceControlStruct { tlvReader.enterStructure(tlvTag) val heatingSource = tlvReader.getUInt(ContextSpecificTag(TAG_HEATING_SOURCE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterHeatingSourceControlStruct(heatingSource) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt index 150b4bc952bad3..f714af6d7b8fbd 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt @@ -17,25 +17,24 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterLoadControlEventStruct ( - val eventID: ByteArray, - val programID: ByteArray?, - val control: UInt, - val deviceClass: ULong, - val enrollmentGroup: Optional, - val criticality: UInt, - val startTime: ULong?, - val transitions: List) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterLoadControlEventStruct( + val eventID: ByteArray, + val programID: ByteArray?, + val control: UInt, + val deviceClass: ULong, + val enrollmentGroup: Optional, + val criticality: UInt, + val startTime: ULong?, + val transitions: List +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventStruct {\n") append("\teventID : $eventID\n") append("\tprogramID : $programID\n") @@ -53,22 +52,22 @@ class DemandResponseLoadControlClusterLoadControlEventStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_EVENT_I_D), eventID) if (programID != null) { - put(ContextSpecificTag(TAG_PROGRAM_I_D), programID) - } else { - putNull(ContextSpecificTag(TAG_PROGRAM_I_D)) - } + put(ContextSpecificTag(TAG_PROGRAM_I_D), programID) + } else { + putNull(ContextSpecificTag(TAG_PROGRAM_I_D)) + } put(ContextSpecificTag(TAG_CONTROL), control) put(ContextSpecificTag(TAG_DEVICE_CLASS), deviceClass) if (enrollmentGroup.isPresent) { - val optenrollmentGroup = enrollmentGroup.get() - put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), optenrollmentGroup) - } + val optenrollmentGroup = enrollmentGroup.get() + put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), optenrollmentGroup) + } put(ContextSpecificTag(TAG_CRITICALITY), criticality) if (startTime != null) { - put(ContextSpecificTag(TAG_START_TIME), startTime) - } else { - putNull(ContextSpecificTag(TAG_START_TIME)) - } + put(ContextSpecificTag(TAG_START_TIME), startTime) + } else { + putNull(ContextSpecificTag(TAG_START_TIME)) + } startArray(ContextSpecificTag(TAG_TRANSITIONS)) for (item in transitions.iterator()) { item.toTlv(AnonymousTag, this) @@ -88,40 +87,61 @@ class DemandResponseLoadControlClusterLoadControlEventStruct ( private const val TAG_START_TIME = 6 private const val TAG_TRANSITIONS = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventStruct { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val programID = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) - null - } + val programID = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) + null + } val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) val deviceClass = tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_CLASS)) - val enrollmentGroup = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) - } else { - Optional.empty() - } + val enrollmentGroup = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) + } else { + Optional.empty() + } val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) - val startTime = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val transitions = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val startTime = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) + null + } + val transitions = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStruct(eventID, programID, control, deviceClass, enrollmentGroup, criticality, startTime, transitions) + return DemandResponseLoadControlClusterLoadControlEventStruct( + eventID, + programID, + control, + deviceClass, + enrollmentGroup, + criticality, + startTime, + transitions + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt index c1643805f9a6bf..6d44b1e020d180 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt @@ -17,24 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterLoadControlEventTransitionStruct ( - val duration: UInt, - val control: UInt, - val temperatureControl: Optional, - val averageLoadControl: Optional, - val dutyCycleControl: Optional, - val powerSavingsControl: Optional, - val heatingSourceControl: Optional) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( + val duration: UInt, + val control: UInt, + val temperatureControl: Optional, + val averageLoadControl: Optional, + val dutyCycleControl: Optional, + val powerSavingsControl: Optional, + val heatingSourceControl: Optional +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventTransitionStruct {\n") append("\tduration : $duration\n") append("\tcontrol : $control\n") @@ -52,25 +50,25 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct ( put(ContextSpecificTag(TAG_DURATION), duration) put(ContextSpecificTag(TAG_CONTROL), control) if (temperatureControl.isPresent) { - val opttemperatureControl = temperatureControl.get() - opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) - } + val opttemperatureControl = temperatureControl.get() + opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) + } if (averageLoadControl.isPresent) { - val optaverageLoadControl = averageLoadControl.get() - optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) - } + val optaverageLoadControl = averageLoadControl.get() + optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) + } if (dutyCycleControl.isPresent) { - val optdutyCycleControl = dutyCycleControl.get() - optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) - } + val optdutyCycleControl = dutyCycleControl.get() + optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) + } if (powerSavingsControl.isPresent) { - val optpowerSavingsControl = powerSavingsControl.get() - optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) - } + val optpowerSavingsControl = powerSavingsControl.get() + optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) + } if (heatingSourceControl.isPresent) { - val optheatingSourceControl = heatingSourceControl.get() - optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) - } + val optheatingSourceControl = heatingSourceControl.get() + optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) + } endStructure() } } @@ -84,39 +82,80 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct ( private const val TAG_POWER_SAVINGS_CONTROL = 5 private const val TAG_HEATING_SOURCE_CONTROL = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventTransitionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { tlvReader.enterStructure(tlvTag) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val averageLoadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val dutyCycleControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val powerSavingsControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val heatingSourceControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - + val temperatureControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv( + ContextSpecificTag(TAG_TEMPERATURE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val averageLoadControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv( + ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val dutyCycleControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv( + ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val powerSavingsControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv( + ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val heatingSourceControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv( + ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventTransitionStruct(duration, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) + return DemandResponseLoadControlClusterLoadControlEventTransitionStruct( + duration, + control, + temperatureControl, + averageLoadControl, + dutyCycleControl, + powerSavingsControl, + heatingSourceControl + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt index 70787ef931f659..289e4b0a1dbebf 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt @@ -17,22 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterLoadControlProgramStruct ( - val programID: ByteArray, - val name: String, - val enrollmentGroup: UInt?, - val randomStartMinutes: UInt?, - val randomDurationMinutes: UInt?) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterLoadControlProgramStruct( + val programID: ByteArray, + val name: String, + val enrollmentGroup: UInt?, + val randomStartMinutes: UInt?, + val randomDurationMinutes: UInt? +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlProgramStruct {\n") append("\tprogramID : $programID\n") append("\tname : $name\n") @@ -48,20 +45,20 @@ class DemandResponseLoadControlClusterLoadControlProgramStruct ( put(ContextSpecificTag(TAG_PROGRAM_I_D), programID) put(ContextSpecificTag(TAG_NAME), name) if (enrollmentGroup != null) { - put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), enrollmentGroup) - } else { - putNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } + put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), enrollmentGroup) + } else { + putNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + } if (randomStartMinutes != null) { - put(ContextSpecificTag(TAG_RANDOM_START_MINUTES), randomStartMinutes) - } else { - putNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - } + put(ContextSpecificTag(TAG_RANDOM_START_MINUTES), randomStartMinutes) + } else { + putNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + } if (randomDurationMinutes != null) { - put(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES), randomDurationMinutes) - } else { - putNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - } + put(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES), randomDurationMinutes) + } else { + putNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + } endStructure() } } @@ -73,32 +70,44 @@ class DemandResponseLoadControlClusterLoadControlProgramStruct ( private const val TAG_RANDOM_START_MINUTES = 3 private const val TAG_RANDOM_DURATION_MINUTES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlProgramStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlProgramStruct { tlvReader.enterStructure(tlvTag) val programID = tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - val enrollmentGroup = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - null - } - val randomStartMinutes = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - null - } - val randomDurationMinutes = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - null - } - + val enrollmentGroup = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + null + } + val randomStartMinutes = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + null + } + val randomDurationMinutes = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlProgramStruct(programID, name, enrollmentGroup, randomStartMinutes, randomDurationMinutes) + return DemandResponseLoadControlClusterLoadControlProgramStruct( + programID, + name, + enrollmentGroup, + randomStartMinutes, + randomDurationMinutes + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt index a06b0011af0b89..30ed601d4ac156 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterPowerSavingsControlStruct ( - val powerSavings: UInt) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterPowerSavingsControlStruct(val powerSavings: UInt) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterPowerSavingsControlStruct {\n") append("\tpowerSavings : $powerSavings\n") append("}\n") @@ -45,10 +40,13 @@ class DemandResponseLoadControlClusterPowerSavingsControlStruct ( companion object { private const val TAG_POWER_SAVINGS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterPowerSavingsControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterPowerSavingsControlStruct { tlvReader.enterStructure(tlvTag) val powerSavings = tlvReader.getUInt(ContextSpecificTag(TAG_POWER_SAVINGS)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterPowerSavingsControlStruct(powerSavings) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt index 70524b6e349fca..925c1db888410a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterTemperatureControlStruct ( - val coolingTempOffset: Optional?, - val heatingtTempOffset: Optional?, - val coolingTempSetpoint: Optional?, - val heatingTempSetpoint: Optional?) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterTemperatureControlStruct( + val coolingTempOffset: Optional?, + val heatingtTempOffset: Optional?, + val coolingTempSetpoint: Optional?, + val heatingTempSetpoint: Optional? +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterTemperatureControlStruct {\n") append("\tcoolingTempOffset : $coolingTempOffset\n") append("\theatingtTempOffset : $heatingtTempOffset\n") @@ -44,37 +42,37 @@ class DemandResponseLoadControlClusterTemperatureControlStruct ( tlvWriter.apply { startStructure(tlvTag) if (coolingTempOffset != null) { - if (coolingTempOffset.isPresent) { - val optcoolingTempOffset = coolingTempOffset.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) - } - } else { - putNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) - } + if (coolingTempOffset.isPresent) { + val optcoolingTempOffset = coolingTempOffset.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) + } + } else { + putNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) + } if (heatingtTempOffset != null) { - if (heatingtTempOffset.isPresent) { - val optheatingtTempOffset = heatingtTempOffset.get() - put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) - } - } else { - putNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) - } + if (heatingtTempOffset.isPresent) { + val optheatingtTempOffset = heatingtTempOffset.get() + put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) + } + } else { + putNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) + } if (coolingTempSetpoint != null) { - if (coolingTempSetpoint.isPresent) { - val optcoolingTempSetpoint = coolingTempSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) - } - } else { - putNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) - } + if (coolingTempSetpoint.isPresent) { + val optcoolingTempSetpoint = coolingTempSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) + } + } else { + putNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) + } if (heatingTempSetpoint != null) { - if (heatingTempSetpoint.isPresent) { - val optheatingTempSetpoint = heatingTempSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) - } - } else { - putNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) - } + if (heatingTempSetpoint.isPresent) { + val optheatingTempSetpoint = heatingTempSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) + } + } else { + putNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) + } endStructure() } } @@ -85,52 +83,64 @@ class DemandResponseLoadControlClusterTemperatureControlStruct ( private const val TAG_COOLING_TEMP_SETPOINT = 2 private const val TAG_HEATING_TEMP_SETPOINT = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterTemperatureControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterTemperatureControlStruct { tlvReader.enterStructure(tlvTag) - val coolingTempOffset = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) - null - } - val heatingtTempOffset = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) - null - } - val coolingTempSetpoint = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) - null - } - val heatingTempSetpoint = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) - null - } - + val coolingTempOffset = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) + null + } + val heatingtTempOffset = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) + null + } + val coolingTempSetpoint = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) + null + } + val heatingTempSetpoint = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterTemperatureControlStruct(coolingTempOffset, heatingtTempOffset, coolingTempSetpoint, heatingTempSetpoint) + return DemandResponseLoadControlClusterTemperatureControlStruct( + coolingTempOffset, + heatingtTempOffset, + coolingTempSetpoint, + heatingTempSetpoint + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt index c5529da5072ea8..0a867ba2296515 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DescriptorClusterDeviceTypeStruct ( - val deviceType: ULong, - val revision: UInt) { - override fun toString(): String = buildString { +class DescriptorClusterDeviceTypeStruct(val deviceType: ULong, val revision: UInt) { + override fun toString(): String = buildString { append("DescriptorClusterDeviceTypeStruct {\n") append("\tdeviceType : $deviceType\n") append("\trevision : $revision\n") @@ -49,11 +43,11 @@ class DescriptorClusterDeviceTypeStruct ( private const val TAG_DEVICE_TYPE = 0 private const val TAG_REVISION = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DescriptorClusterDeviceTypeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DescriptorClusterDeviceTypeStruct { tlvReader.enterStructure(tlvTag) val deviceType = tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_TYPE)) val revision = tlvReader.getUInt(ContextSpecificTag(TAG_REVISION)) - + tlvReader.exitContainer() return DescriptorClusterDeviceTypeStruct(deviceType, revision) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt index 89967a1445d75d..91d33d5c0fe2e5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DescriptorClusterSemanticTagStruct ( - val mfgCode: UInt?, - val namespaceID: UInt, - val tag: UInt, - val label: Optional?) { - override fun toString(): String = buildString { +class DescriptorClusterSemanticTagStruct( + val mfgCode: UInt?, + val namespaceID: UInt, + val tag: UInt, + val label: Optional? +) { + override fun toString(): String = buildString { append("DescriptorClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tnamespaceID : $namespaceID\n") @@ -44,20 +42,20 @@ class DescriptorClusterSemanticTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode != null) { - put(ContextSpecificTag(TAG_MFG_CODE), mfgCode) - } else { - putNull(ContextSpecificTag(TAG_MFG_CODE)) - } + put(ContextSpecificTag(TAG_MFG_CODE), mfgCode) + } else { + putNull(ContextSpecificTag(TAG_MFG_CODE)) + } put(ContextSpecificTag(TAG_NAMESPACE_I_D), namespaceID) put(ContextSpecificTag(TAG_TAG), tag) if (label != null) { - if (label.isPresent) { - val optlabel = label.get() - put(ContextSpecificTag(TAG_LABEL), optlabel) - } - } else { - putNull(ContextSpecificTag(TAG_LABEL)) - } + if (label.isPresent) { + val optlabel = label.get() + put(ContextSpecificTag(TAG_LABEL), optlabel) + } + } else { + putNull(ContextSpecificTag(TAG_LABEL)) + } endStructure() } } @@ -68,27 +66,29 @@ class DescriptorClusterSemanticTagStruct ( private const val TAG_TAG = 2 private const val TAG_LABEL = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DescriptorClusterSemanticTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DescriptorClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) - null - } + val mfgCode = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) + null + } val namespaceID = tlvReader.getUInt(ContextSpecificTag(TAG_NAMESPACE_I_D)) val tag = tlvReader.getUInt(ContextSpecificTag(TAG_TAG)) - val label = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) - null - } - + val label = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) + null + } + tlvReader.exitContainer() return DescriptorClusterSemanticTagStruct(mfgCode, namespaceID, tag, label) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt index b473bdd6ebe7c3..8389173d80aca7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterConstraintsStruct ( - val startTime: ULong, - val duration: ULong, - val nominalPower: Optional, - val maximumEnergy: Optional, - val loadControl: Optional) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterConstraintsStruct( + val startTime: ULong, + val duration: ULong, + val nominalPower: Optional, + val maximumEnergy: Optional, + val loadControl: Optional +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterConstraintsStruct {\n") append("\tstartTime : $startTime\n") append("\tduration : $duration\n") @@ -48,17 +46,17 @@ class DeviceEnergyManagementClusterConstraintsStruct ( put(ContextSpecificTag(TAG_START_TIME), startTime) put(ContextSpecificTag(TAG_DURATION), duration) if (nominalPower.isPresent) { - val optnominalPower = nominalPower.get() - put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) - } + val optnominalPower = nominalPower.get() + put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) + } if (maximumEnergy.isPresent) { - val optmaximumEnergy = maximumEnergy.get() - put(ContextSpecificTag(TAG_MAXIMUM_ENERGY), optmaximumEnergy) - } + val optmaximumEnergy = maximumEnergy.get() + put(ContextSpecificTag(TAG_MAXIMUM_ENERGY), optmaximumEnergy) + } if (loadControl.isPresent) { - val optloadControl = loadControl.get() - put(ContextSpecificTag(TAG_LOAD_CONTROL), optloadControl) - } + val optloadControl = loadControl.get() + put(ContextSpecificTag(TAG_LOAD_CONTROL), optloadControl) + } endStructure() } } @@ -70,29 +68,38 @@ class DeviceEnergyManagementClusterConstraintsStruct ( private const val TAG_MAXIMUM_ENERGY = 3 private const val TAG_LOAD_CONTROL = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterConstraintsStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterConstraintsStruct { tlvReader.enterStructure(tlvTag) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val maximumEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) - } else { - Optional.empty() - } - val loadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_LOAD_CONTROL))) - } else { - Optional.empty() - } - + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val maximumEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) + } else { + Optional.empty() + } + val loadControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_LOAD_CONTROL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterConstraintsStruct(startTime, duration, nominalPower, maximumEnergy, loadControl) + return DeviceEnergyManagementClusterConstraintsStruct( + startTime, + duration, + nominalPower, + maximumEnergy, + loadControl + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt index d996e8c0c944d0..1d74d861c90b76 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterCostStruct ( - val costType: UInt, - val value: Long, - val decimalPoints: UInt, - val currency: Optional) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterCostStruct( + val costType: UInt, + val value: Long, + val decimalPoints: UInt, + val currency: Optional +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterCostStruct {\n") append("\tcostType : $costType\n") append("\tvalue : $value\n") @@ -47,9 +45,9 @@ class DeviceEnergyManagementClusterCostStruct ( put(ContextSpecificTag(TAG_VALUE), value) put(ContextSpecificTag(TAG_DECIMAL_POINTS), decimalPoints) if (currency.isPresent) { - val optcurrency = currency.get() - put(ContextSpecificTag(TAG_CURRENCY), optcurrency) - } + val optcurrency = currency.get() + put(ContextSpecificTag(TAG_CURRENCY), optcurrency) + } endStructure() } } @@ -60,17 +58,18 @@ class DeviceEnergyManagementClusterCostStruct ( private const val TAG_DECIMAL_POINTS = 2 private const val TAG_CURRENCY = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterCostStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterCostStruct { tlvReader.enterStructure(tlvTag) val costType = tlvReader.getUInt(ContextSpecificTag(TAG_COST_TYPE)) val value = tlvReader.getLong(ContextSpecificTag(TAG_VALUE)) val decimalPoints = tlvReader.getUInt(ContextSpecificTag(TAG_DECIMAL_POINTS)) - val currency = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CURRENCY))) - } else { - Optional.empty() - } - + val currency = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CURRENCY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return DeviceEnergyManagementClusterCostStruct(costType, value, decimalPoints, currency) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index c4b479410fde59..ad9120a2327983 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -17,26 +17,25 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterForecastStruct ( - val forecastID: ULong, - val activeSlotNumber: UInt?, - val startTime: ULong, - val endTime: ULong, - val earliestStartTime: Optional?, - val latestEndTime: Optional, - val isPausable: Boolean, - val slots: List, - val forecastUpdateReason: UInt) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterForecastStruct( + val forecastID: ULong, + val activeSlotNumber: UInt?, + val startTime: ULong, + val endTime: ULong, + val earliestStartTime: Optional?, + val latestEndTime: Optional, + val isPausable: Boolean, + val slots: List, + val forecastUpdateReason: UInt +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterForecastStruct {\n") append("\tforecastID : $forecastID\n") append("\tactiveSlotNumber : $activeSlotNumber\n") @@ -55,24 +54,24 @@ class DeviceEnergyManagementClusterForecastStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_FORECAST_I_D), forecastID) if (activeSlotNumber != null) { - put(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER), activeSlotNumber) - } else { - putNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - } + put(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER), activeSlotNumber) + } else { + putNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + } put(ContextSpecificTag(TAG_START_TIME), startTime) put(ContextSpecificTag(TAG_END_TIME), endTime) if (earliestStartTime != null) { - if (earliestStartTime.isPresent) { - val optearliestStartTime = earliestStartTime.get() - put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) - } - } else { - putNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) - } + if (earliestStartTime.isPresent) { + val optearliestStartTime = earliestStartTime.get() + put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) + } + } else { + putNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) + } if (latestEndTime.isPresent) { - val optlatestEndTime = latestEndTime.get() - put(ContextSpecificTag(TAG_LATEST_END_TIME), optlatestEndTime) - } + val optlatestEndTime = latestEndTime.get() + put(ContextSpecificTag(TAG_LATEST_END_TIME), optlatestEndTime) + } put(ContextSpecificTag(TAG_IS_PAUSABLE), isPausable) startArray(ContextSpecificTag(TAG_SLOTS)) for (item in slots.iterator()) { @@ -95,45 +94,59 @@ class DeviceEnergyManagementClusterForecastStruct ( private const val TAG_SLOTS = 7 private const val TAG_FORECAST_UPDATE_REASON = 8 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterForecastStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) val forecastID = tlvReader.getULong(ContextSpecificTag(TAG_FORECAST_I_D)) - val activeSlotNumber = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - null - } + val activeSlotNumber = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + null + } val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getULong(ContextSpecificTag(TAG_END_TIME)) - val earliestStartTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EARLIEST_START_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) - null - } - val latestEndTime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_LATEST_END_TIME))) - } else { - Optional.empty() - } + val earliestStartTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EARLIEST_START_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) + null + } + val latestEndTime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_LATEST_END_TIME))) + } else { + Optional.empty() + } val isPausable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSABLE)) - val slots = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val slots = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } val forecastUpdateReason = tlvReader.getUInt(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterForecastStruct(forecastID, activeSlotNumber, startTime, endTime, earliestStartTime, latestEndTime, isPausable, slots, forecastUpdateReason) + return DeviceEnergyManagementClusterForecastStruct( + forecastID, + activeSlotNumber, + startTime, + endTime, + earliestStartTime, + latestEndTime, + isPausable, + slots, + forecastUpdateReason + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt index ab2c97d763c345..e2172a7b33b94e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterPowerAdjustCapabilityStruct ( - val powerAdjustCapability: List?, - val cause: UInt) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterPowerAdjustCapabilityStruct( + val powerAdjustCapability: List?, + val cause: UInt +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterPowerAdjustCapabilityStruct {\n") append("\tpowerAdjustCapability : $powerAdjustCapability\n") append("\tcause : $cause\n") @@ -40,14 +38,14 @@ class DeviceEnergyManagementClusterPowerAdjustCapabilityStruct ( tlvWriter.apply { startStructure(tlvTag) if (powerAdjustCapability != null) { - startArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) - for (item in powerAdjustCapability.iterator()) { - item.toTlv(AnonymousTag, this) + startArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + for (item in powerAdjustCapability.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } else { + putNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) } - endArray() - } else { - putNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) - } put(ContextSpecificTag(TAG_CAUSE), cause) endStructure() } @@ -57,22 +55,26 @@ class DeviceEnergyManagementClusterPowerAdjustCapabilityStruct ( private const val TAG_POWER_ADJUST_CAPABILITY = 0 private const val TAG_CAUSE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustCapabilityStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterPowerAdjustCapabilityStruct { tlvReader.enterStructure(tlvTag) - val powerAdjustCapability = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) - null - } + val powerAdjustCapability = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + null + } val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterPowerAdjustCapabilityStruct(powerAdjustCapability, cause) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt index 20385dd1ca78e2..7021aa2720949e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterPowerAdjustStruct ( - val minPower: Long, - val maxPower: Long, - val minDuration: ULong, - val maxDuration: ULong) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterPowerAdjustStruct( + val minPower: Long, + val maxPower: Long, + val minDuration: ULong, + val maxDuration: ULong +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterPowerAdjustStruct {\n") append("\tminPower : $minPower\n") append("\tmaxPower : $maxPower\n") @@ -57,16 +54,21 @@ class DeviceEnergyManagementClusterPowerAdjustStruct ( private const val TAG_MIN_DURATION = 2 private const val TAG_MAX_DURATION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterPowerAdjustStruct { tlvReader.enterStructure(tlvTag) val minPower = tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER)) val maxPower = tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER)) val minDuration = tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION)) val maxDuration = tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterPowerAdjustStruct(minPower, maxPower, minDuration, maxDuration) + return DeviceEnergyManagementClusterPowerAdjustStruct( + minPower, + maxPower, + minDuration, + maxDuration + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt index b061eaca03b169..22aa9bdae17234 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterSlotAdjustmentStruct ( - val slotIndex: UInt, - val nominalPower: Optional, - val duration: ULong) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterSlotAdjustmentStruct( + val slotIndex: UInt, + val nominalPower: Optional, + val duration: ULong +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterSlotAdjustmentStruct {\n") append("\tslotIndex : $slotIndex\n") append("\tnominalPower : $nominalPower\n") @@ -43,9 +41,9 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_SLOT_INDEX), slotIndex) if (nominalPower.isPresent) { - val optnominalPower = nominalPower.get() - put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) - } + val optnominalPower = nominalPower.get() + put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) + } put(ContextSpecificTag(TAG_DURATION), duration) endStructure() } @@ -56,16 +54,20 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct ( private const val TAG_NOMINAL_POWER = 1 private const val TAG_DURATION = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterSlotAdjustmentStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterSlotAdjustmentStruct { tlvReader.enterStructure(tlvTag) val slotIndex = tlvReader.getUInt(ContextSpecificTag(TAG_SLOT_INDEX)) - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterSlotAdjustmentStruct(slotIndex, nominalPower, duration) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index 0533aa266a738e..f6d35be87d59f3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -17,35 +17,34 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterSlotStruct ( - val minDuration: ULong, - val maxDuration: ULong, - val defaultDuration: ULong, - val elapsedSlotTime: ULong, - val remainingSlotTime: ULong, - val slotIsPausable: Optional, - val minPauseDuration: Optional, - val maxPauseDuration: Optional, - val manufacturerESAState: Optional, - val nominalPower: Optional, - val minPower: Optional, - val maxPower: Optional, - val nominalEnergy: Optional, - val costs: Optional>, - val minPowerAdjustment: Optional, - val maxPowerAdjustment: Optional, - val minDurationAdjustment: Optional, - val maxDurationAdjustment: Optional) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterSlotStruct( + val minDuration: ULong, + val maxDuration: ULong, + val defaultDuration: ULong, + val elapsedSlotTime: ULong, + val remainingSlotTime: ULong, + val slotIsPausable: Optional, + val minPauseDuration: Optional, + val maxPauseDuration: Optional, + val manufacturerESAState: Optional, + val nominalPower: Optional, + val minPower: Optional, + val maxPower: Optional, + val nominalEnergy: Optional, + val costs: Optional>, + val minPowerAdjustment: Optional, + val maxPowerAdjustment: Optional, + val minDurationAdjustment: Optional, + val maxDurationAdjustment: Optional +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterSlotStruct {\n") append("\tminDuration : $minDuration\n") append("\tmaxDuration : $maxDuration\n") @@ -77,61 +76,61 @@ class DeviceEnergyManagementClusterSlotStruct ( put(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME), elapsedSlotTime) put(ContextSpecificTag(TAG_REMAINING_SLOT_TIME), remainingSlotTime) if (slotIsPausable.isPresent) { - val optslotIsPausable = slotIsPausable.get() - put(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE), optslotIsPausable) - } + val optslotIsPausable = slotIsPausable.get() + put(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE), optslotIsPausable) + } if (minPauseDuration.isPresent) { - val optminPauseDuration = minPauseDuration.get() - put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), optminPauseDuration) - } + val optminPauseDuration = minPauseDuration.get() + put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), optminPauseDuration) + } if (maxPauseDuration.isPresent) { - val optmaxPauseDuration = maxPauseDuration.get() - put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), optmaxPauseDuration) - } + val optmaxPauseDuration = maxPauseDuration.get() + put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), optmaxPauseDuration) + } if (manufacturerESAState.isPresent) { - val optmanufacturerESAState = manufacturerESAState.get() - put(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE), optmanufacturerESAState) - } + val optmanufacturerESAState = manufacturerESAState.get() + put(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE), optmanufacturerESAState) + } if (nominalPower.isPresent) { - val optnominalPower = nominalPower.get() - put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) - } + val optnominalPower = nominalPower.get() + put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) + } if (minPower.isPresent) { - val optminPower = minPower.get() - put(ContextSpecificTag(TAG_MIN_POWER), optminPower) - } + val optminPower = minPower.get() + put(ContextSpecificTag(TAG_MIN_POWER), optminPower) + } if (maxPower.isPresent) { - val optmaxPower = maxPower.get() - put(ContextSpecificTag(TAG_MAX_POWER), optmaxPower) - } + val optmaxPower = maxPower.get() + put(ContextSpecificTag(TAG_MAX_POWER), optmaxPower) + } if (nominalEnergy.isPresent) { - val optnominalEnergy = nominalEnergy.get() - put(ContextSpecificTag(TAG_NOMINAL_ENERGY), optnominalEnergy) - } + val optnominalEnergy = nominalEnergy.get() + put(ContextSpecificTag(TAG_NOMINAL_ENERGY), optnominalEnergy) + } if (costs.isPresent) { - val optcosts = costs.get() - startArray(ContextSpecificTag(TAG_COSTS)) - for (item in optcosts.iterator()) { - item.toTlv(AnonymousTag, this) + val optcosts = costs.get() + startArray(ContextSpecificTag(TAG_COSTS)) + for (item in optcosts.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } if (minPowerAdjustment.isPresent) { - val optminPowerAdjustment = minPowerAdjustment.get() - put(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT), optminPowerAdjustment) - } + val optminPowerAdjustment = minPowerAdjustment.get() + put(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT), optminPowerAdjustment) + } if (maxPowerAdjustment.isPresent) { - val optmaxPowerAdjustment = maxPowerAdjustment.get() - put(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT), optmaxPowerAdjustment) - } + val optmaxPowerAdjustment = maxPowerAdjustment.get() + put(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT), optmaxPowerAdjustment) + } if (minDurationAdjustment.isPresent) { - val optminDurationAdjustment = minDurationAdjustment.get() - put(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT), optminDurationAdjustment) - } + val optminDurationAdjustment = minDurationAdjustment.get() + put(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT), optminDurationAdjustment) + } if (maxDurationAdjustment.isPresent) { - val optmaxDurationAdjustment = maxDurationAdjustment.get() - put(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT), optmaxDurationAdjustment) - } + val optmaxDurationAdjustment = maxDurationAdjustment.get() + put(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT), optmaxDurationAdjustment) + } endStructure() } } @@ -156,88 +155,122 @@ class DeviceEnergyManagementClusterSlotStruct ( private const val TAG_MIN_DURATION_ADJUSTMENT = 16 private const val TAG_MAX_DURATION_ADJUSTMENT = 17 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterSlotStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterSlotStruct { tlvReader.enterStructure(tlvTag) val minDuration = tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION)) val maxDuration = tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION)) val defaultDuration = tlvReader.getULong(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPausable = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) - } else { - Optional.empty() - } - val minPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) - } else { - Optional.empty() - } - val maxPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) - } else { - Optional.empty() - } - val manufacturerESAState = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) - } else { - Optional.empty() - } - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val minPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) - } else { - Optional.empty() - } - val maxPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) - } else { - Optional.empty() - } - val nominalEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) - } else { - Optional.empty() - } - val costs = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val minPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val minDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - + val slotIsPausable = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) + } else { + Optional.empty() + } + val minPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) + } else { + Optional.empty() + } + val maxPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) + } else { + Optional.empty() + } + val manufacturerESAState = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) + } else { + Optional.empty() + } + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val minPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) + } else { + Optional.empty() + } + val maxPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) + } else { + Optional.empty() + } + val nominalEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) + } else { + Optional.empty() + } + val costs = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val minPowerAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxPowerAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val minDurationAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxDurationAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterSlotStruct(minDuration, maxDuration, defaultDuration, elapsedSlotTime, remainingSlotTime, slotIsPausable, minPauseDuration, maxPauseDuration, manufacturerESAState, nominalPower, minPower, maxPower, nominalEnergy, costs, minPowerAdjustment, maxPowerAdjustment, minDurationAdjustment, maxDurationAdjustment) + return DeviceEnergyManagementClusterSlotStruct( + minDuration, + maxDuration, + defaultDuration, + elapsedSlotTime, + remainingSlotTime, + slotIsPausable, + minPauseDuration, + maxPauseDuration, + manufacturerESAState, + nominalPower, + minPower, + maxPower, + nominalEnergy, + costs, + minPowerAdjustment, + maxPowerAdjustment, + minDurationAdjustment, + maxDurationAdjustment + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementModeClusterModeOptionStruct.kt index 4fbe4cecea00a4..6940454d5d2383 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class DeviceEnergyManagementModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,22 @@ class DeviceEnergyManagementModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementModeClusterModeOptionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return DeviceEnergyManagementModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementModeClusterModeTagStruct.kt index 4786e339f92afd..b47b743cbff0e8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class DeviceEnergyManagementModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("DeviceEnergyManagementModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class DeviceEnergyManagementModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class DeviceEnergyManagementModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return DeviceEnergyManagementModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt index 04305789265487..0cbbf8fb8c37eb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DishwasherModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class DishwasherModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("DishwasherModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class DishwasherModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return DishwasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt index f2615f2ddeb01e..916f58bdab72e6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DishwasherModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("DishwasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class DishwasherModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class DishwasherModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return DishwasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt index 108dd2b0efe922..5ee8045b4d17ed 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterCredentialStruct ( - val credentialType: UInt, - val credentialIndex: UInt) { - override fun toString(): String = buildString { +class DoorLockClusterCredentialStruct(val credentialType: UInt, val credentialIndex: UInt) { + override fun toString(): String = buildString { append("DoorLockClusterCredentialStruct {\n") append("\tcredentialType : $credentialType\n") append("\tcredentialIndex : $credentialIndex\n") @@ -49,11 +43,11 @@ class DoorLockClusterCredentialStruct ( private const val TAG_CREDENTIAL_TYPE = 0 private const val TAG_CREDENTIAL_INDEX = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterCredentialStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterCredentialStruct { tlvReader.enterStructure(tlvTag) val credentialType = tlvReader.getUInt(ContextSpecificTag(TAG_CREDENTIAL_TYPE)) val credentialIndex = tlvReader.getUInt(ContextSpecificTag(TAG_CREDENTIAL_INDEX)) - + tlvReader.exitContainer() return DoorLockClusterCredentialStruct(credentialType, credentialIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt index be7a90405c6bc5..e16d78d8de18e1 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct ( - val importedResetTimestamp: Optional?, - val exportedResetTimestamp: Optional?, - val importedResetSystime: Optional?, - val exportedResetSystime: Optional?) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( + val importedResetTimestamp: Optional?, + val exportedResetTimestamp: Optional?, + val importedResetSystime: Optional?, + val exportedResetSystime: Optional? +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct {\n") append("\timportedResetTimestamp : $importedResetTimestamp\n") append("\texportedResetTimestamp : $exportedResetTimestamp\n") @@ -44,37 +42,37 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct ( tlvWriter.apply { startStructure(tlvTag) if (importedResetTimestamp != null) { - if (importedResetTimestamp.isPresent) { - val optimportedResetTimestamp = importedResetTimestamp.get() - put(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP), optimportedResetTimestamp) - } - } else { - putNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) - } + if (importedResetTimestamp.isPresent) { + val optimportedResetTimestamp = importedResetTimestamp.get() + put(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP), optimportedResetTimestamp) + } + } else { + putNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) + } if (exportedResetTimestamp != null) { - if (exportedResetTimestamp.isPresent) { - val optexportedResetTimestamp = exportedResetTimestamp.get() - put(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP), optexportedResetTimestamp) - } - } else { - putNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) - } + if (exportedResetTimestamp.isPresent) { + val optexportedResetTimestamp = exportedResetTimestamp.get() + put(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP), optexportedResetTimestamp) + } + } else { + putNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) + } if (importedResetSystime != null) { - if (importedResetSystime.isPresent) { - val optimportedResetSystime = importedResetSystime.get() - put(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME), optimportedResetSystime) - } - } else { - putNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) - } + if (importedResetSystime.isPresent) { + val optimportedResetSystime = importedResetSystime.get() + put(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME), optimportedResetSystime) + } + } else { + putNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) + } if (exportedResetSystime != null) { - if (exportedResetSystime.isPresent) { - val optexportedResetSystime = exportedResetSystime.get() - put(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME), optexportedResetSystime) - } - } else { - putNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) - } + if (exportedResetSystime.isPresent) { + val optexportedResetSystime = exportedResetSystime.get() + put(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME), optexportedResetSystime) + } + } else { + putNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) + } endStructure() } } @@ -85,52 +83,64 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct ( private const val TAG_IMPORTED_RESET_SYSTIME = 2 private const val TAG_EXPORTED_RESET_SYSTIME = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct { tlvReader.enterStructure(tlvTag) - val importedResetTimestamp = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) - null - } - val exportedResetTimestamp = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) - null - } - val importedResetSystime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) - null - } - val exportedResetSystime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) - null - } - + val importedResetTimestamp = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) + null + } + val exportedResetTimestamp = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) + null + } + val importedResetSystime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) + null + } + val exportedResetSystime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) + null + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct(importedResetTimestamp, exportedResetTimestamp, importedResetSystime, exportedResetSystime) + return ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( + importedResetTimestamp, + exportedResetTimestamp, + importedResetSystime, + exportedResetSystime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt index 498c715482bd90..bbce3fc7d16ff7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct ( - val energy: Long, - val startTimestamp: Optional, - val endTimestamp: Optional, - val startSystime: Optional, - val endSystime: Optional) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + val energy: Long, + val startTimestamp: Optional, + val endTimestamp: Optional, + val startSystime: Optional, + val endSystime: Optional +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterEnergyMeasurementStruct {\n") append("\tenergy : $energy\n") append("\tstartTimestamp : $startTimestamp\n") @@ -47,21 +45,21 @@ class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ENERGY), energy) if (startTimestamp.isPresent) { - val optstartTimestamp = startTimestamp.get() - put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) - } + val optstartTimestamp = startTimestamp.get() + put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) + } if (endTimestamp.isPresent) { - val optendTimestamp = endTimestamp.get() - put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) - } + val optendTimestamp = endTimestamp.get() + put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) + } if (startSystime.isPresent) { - val optstartSystime = startSystime.get() - put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) - } + val optstartSystime = startSystime.get() + put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) + } if (endSystime.isPresent) { - val optendSystime = endSystime.get() - put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) - } + val optendSystime = endSystime.get() + put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) + } endStructure() } } @@ -73,33 +71,46 @@ class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct ( private const val TAG_START_SYSTIME = 3 private const val TAG_END_SYSTIME = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { tlvReader.enterStructure(tlvTag) val energy = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY)) - val startTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) - } else { - Optional.empty() - } - val endTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) - } else { - Optional.empty() - } - val startSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) - } else { - Optional.empty() - } - val endSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) - } else { - Optional.empty() - } - + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct(energy, startTimestamp, endTimestamp, startSystime, endSystime) + return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + energy, + startTimestamp, + endTimestamp, + startSystime, + endSystime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt index 53795eacfd0bda..8ce0529f9cd457 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -17,25 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct ( - val rangeMin: Long, - val rangeMax: Long, - val percentMax: Optional, - val percentMin: Optional, - val percentTypical: Optional, - val fixedMax: Optional, - val fixedMin: Optional, - val fixedTypical: Optional) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + val rangeMin: Long, + val rangeMax: Long, + val percentMax: Optional, + val percentMin: Optional, + val percentTypical: Optional, + val fixedMax: Optional, + val fixedMin: Optional, + val fixedTypical: Optional +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct {\n") append("\trangeMin : $rangeMin\n") append("\trangeMax : $rangeMax\n") @@ -54,29 +52,29 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct ( put(ContextSpecificTag(TAG_RANGE_MIN), rangeMin) put(ContextSpecificTag(TAG_RANGE_MAX), rangeMax) if (percentMax.isPresent) { - val optpercentMax = percentMax.get() - put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) - } + val optpercentMax = percentMax.get() + put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) + } if (percentMin.isPresent) { - val optpercentMin = percentMin.get() - put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) - } + val optpercentMin = percentMin.get() + put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) + } if (percentTypical.isPresent) { - val optpercentTypical = percentTypical.get() - put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) - } + val optpercentTypical = percentTypical.get() + put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) + } if (fixedMax.isPresent) { - val optfixedMax = fixedMax.get() - put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) - } + val optfixedMax = fixedMax.get() + put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) + } if (fixedMin.isPresent) { - val optfixedMin = fixedMin.get() - put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) - } + val optfixedMin = fixedMin.get() + put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) + } if (fixedTypical.isPresent) { - val optfixedTypical = fixedTypical.get() - put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) - } + val optfixedTypical = fixedTypical.get() + put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) + } endStructure() } } @@ -91,44 +89,62 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct ( private const val TAG_FIXED_MIN = 6 private const val TAG_FIXED_TYPICAL = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { tlvReader.enterStructure(tlvTag) val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) - val percentMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) - } else { - Optional.empty() - } - val percentMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) - } else { - Optional.empty() - } - val percentTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) - } else { - Optional.empty() - } - val fixedMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) - } else { - Optional.empty() - } - val fixedMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) - } else { - Optional.empty() - } - val fixedTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) - } else { - Optional.empty() - } - + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct(rangeMin, rangeMax, percentMax, percentMin, percentTypical, fixedMax, fixedMin, fixedTypical) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt index 25bd74a73e38b7..3c33b23cb9e505 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt @@ -20,19 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct ( - val measurementType: UInt, - val measured: Boolean, - val minMeasuredValue: Long, - val maxMeasuredValue: Long, - val accuracyRanges: List) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + val measurementType: UInt, + val measured: Boolean, + val minMeasuredValue: Long, + val maxMeasuredValue: Long, + val accuracyRanges: List +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct {\n") append("\tmeasurementType : $measurementType\n") append("\tmeasured : $measured\n") @@ -65,23 +63,38 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct ( private const val TAG_MAX_MEASURED_VALUE = 3 private const val TAG_ACCURACY_RANGES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUInt(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) - val accuracyRanges = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct(measurementType, measured, minMeasuredValue, maxMeasuredValue, accuracyRanges) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt index b3703e4da9ce70..dd4286af08c7f2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalPowerMeasurementClusterHarmonicMeasurementStruct ( - val order: UInt, - val measurement: Long?) { - override fun toString(): String = buildString { +class ElectricalPowerMeasurementClusterHarmonicMeasurementStruct( + val order: UInt, + val measurement: Long? +) { + override fun toString(): String = buildString { append("ElectricalPowerMeasurementClusterHarmonicMeasurementStruct {\n") append("\torder : $order\n") append("\tmeasurement : $measurement\n") @@ -41,10 +38,10 @@ class ElectricalPowerMeasurementClusterHarmonicMeasurementStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ORDER), order) if (measurement != null) { - put(ContextSpecificTag(TAG_MEASUREMENT), measurement) - } else { - putNull(ContextSpecificTag(TAG_MEASUREMENT)) - } + put(ContextSpecificTag(TAG_MEASUREMENT), measurement) + } else { + putNull(ContextSpecificTag(TAG_MEASUREMENT)) + } endStructure() } } @@ -53,16 +50,20 @@ class ElectricalPowerMeasurementClusterHarmonicMeasurementStruct ( private const val TAG_ORDER = 0 private const val TAG_MEASUREMENT = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalPowerMeasurementClusterHarmonicMeasurementStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterHarmonicMeasurementStruct { tlvReader.enterStructure(tlvTag) val order = tlvReader.getUInt(ContextSpecificTag(TAG_ORDER)) - val measurement = if (!tlvReader.isNull()) { - tlvReader.getLong(ContextSpecificTag(TAG_MEASUREMENT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MEASUREMENT)) - null - } - + val measurement = + if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_MEASUREMENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MEASUREMENT)) + null + } + tlvReader.exitContainer() return ElectricalPowerMeasurementClusterHarmonicMeasurementStruct(order, measurement) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt index c9a917771861a0..b937601980e488 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -17,25 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct ( - val rangeMin: Long, - val rangeMax: Long, - val percentMax: Optional, - val percentMin: Optional, - val percentTypical: Optional, - val fixedMax: Optional, - val fixedMin: Optional, - val fixedTypical: Optional) { - override fun toString(): String = buildString { +class ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( + val rangeMin: Long, + val rangeMax: Long, + val percentMax: Optional, + val percentMin: Optional, + val percentTypical: Optional, + val fixedMax: Optional, + val fixedMin: Optional, + val fixedTypical: Optional +) { + override fun toString(): String = buildString { append("ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct {\n") append("\trangeMin : $rangeMin\n") append("\trangeMax : $rangeMax\n") @@ -54,29 +52,29 @@ class ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct ( put(ContextSpecificTag(TAG_RANGE_MIN), rangeMin) put(ContextSpecificTag(TAG_RANGE_MAX), rangeMax) if (percentMax.isPresent) { - val optpercentMax = percentMax.get() - put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) - } + val optpercentMax = percentMax.get() + put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) + } if (percentMin.isPresent) { - val optpercentMin = percentMin.get() - put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) - } + val optpercentMin = percentMin.get() + put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) + } if (percentTypical.isPresent) { - val optpercentTypical = percentTypical.get() - put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) - } + val optpercentTypical = percentTypical.get() + put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) + } if (fixedMax.isPresent) { - val optfixedMax = fixedMax.get() - put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) - } + val optfixedMax = fixedMax.get() + put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) + } if (fixedMin.isPresent) { - val optfixedMin = fixedMin.get() - put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) - } + val optfixedMin = fixedMin.get() + put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) + } if (fixedTypical.isPresent) { - val optfixedTypical = fixedTypical.get() - put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) - } + val optfixedTypical = fixedTypical.get() + put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) + } endStructure() } } @@ -91,44 +89,62 @@ class ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct ( private const val TAG_FIXED_MIN = 6 private const val TAG_FIXED_TYPICAL = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct { tlvReader.enterStructure(tlvTag) val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) - val percentMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) - } else { - Optional.empty() - } - val percentMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) - } else { - Optional.empty() - } - val percentTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) - } else { - Optional.empty() - } - val fixedMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) - } else { - Optional.empty() - } - val fixedMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) - } else { - Optional.empty() - } - val fixedTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) - } else { - Optional.empty() - } - + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct(rangeMin, rangeMax, percentMax, percentMin, percentTypical, fixedMax, fixedMin, fixedTypical) + return ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt index d131edc7e01767..8197ccc39696ae 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt @@ -20,19 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalPowerMeasurementClusterMeasurementAccuracyStruct ( - val measurementType: UInt, - val measured: Boolean, - val minMeasuredValue: Long, - val maxMeasuredValue: Long, - val accuracyRanges: List) { - override fun toString(): String = buildString { +class ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( + val measurementType: UInt, + val measured: Boolean, + val minMeasuredValue: Long, + val maxMeasuredValue: Long, + val accuracyRanges: List +) { + override fun toString(): String = buildString { append("ElectricalPowerMeasurementClusterMeasurementAccuracyStruct {\n") append("\tmeasurementType : $measurementType\n") append("\tmeasured : $measured\n") @@ -65,23 +63,38 @@ class ElectricalPowerMeasurementClusterMeasurementAccuracyStruct ( private const val TAG_MAX_MEASURED_VALUE = 3 private const val TAG_ACCURACY_RANGES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalPowerMeasurementClusterMeasurementAccuracyStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementAccuracyStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUInt(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) - val accuracyRanges = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return ElectricalPowerMeasurementClusterMeasurementAccuracyStruct(measurementType, measured, minMeasuredValue, maxMeasuredValue, accuracyRanges) + return ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt index e2947e40c2439b..8ddb817032d7f3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt @@ -17,28 +17,26 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalPowerMeasurementClusterMeasurementRangeStruct ( - val measurementType: UInt, - val min: Long, - val max: Long, - val startTimestamp: Optional, - val endTimestamp: Optional, - val minTimestamp: Optional, - val maxTimestamp: Optional, - val startSystime: Optional, - val endSystime: Optional, - val minSystime: Optional, - val maxSystime: Optional) { - override fun toString(): String = buildString { +class ElectricalPowerMeasurementClusterMeasurementRangeStruct( + val measurementType: UInt, + val min: Long, + val max: Long, + val startTimestamp: Optional, + val endTimestamp: Optional, + val minTimestamp: Optional, + val maxTimestamp: Optional, + val startSystime: Optional, + val endSystime: Optional, + val minSystime: Optional, + val maxSystime: Optional +) { + override fun toString(): String = buildString { append("ElectricalPowerMeasurementClusterMeasurementRangeStruct {\n") append("\tmeasurementType : $measurementType\n") append("\tmin : $min\n") @@ -61,37 +59,37 @@ class ElectricalPowerMeasurementClusterMeasurementRangeStruct ( put(ContextSpecificTag(TAG_MIN), min) put(ContextSpecificTag(TAG_MAX), max) if (startTimestamp.isPresent) { - val optstartTimestamp = startTimestamp.get() - put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) - } + val optstartTimestamp = startTimestamp.get() + put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) + } if (endTimestamp.isPresent) { - val optendTimestamp = endTimestamp.get() - put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) - } + val optendTimestamp = endTimestamp.get() + put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) + } if (minTimestamp.isPresent) { - val optminTimestamp = minTimestamp.get() - put(ContextSpecificTag(TAG_MIN_TIMESTAMP), optminTimestamp) - } + val optminTimestamp = minTimestamp.get() + put(ContextSpecificTag(TAG_MIN_TIMESTAMP), optminTimestamp) + } if (maxTimestamp.isPresent) { - val optmaxTimestamp = maxTimestamp.get() - put(ContextSpecificTag(TAG_MAX_TIMESTAMP), optmaxTimestamp) - } + val optmaxTimestamp = maxTimestamp.get() + put(ContextSpecificTag(TAG_MAX_TIMESTAMP), optmaxTimestamp) + } if (startSystime.isPresent) { - val optstartSystime = startSystime.get() - put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) - } + val optstartSystime = startSystime.get() + put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) + } if (endSystime.isPresent) { - val optendSystime = endSystime.get() - put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) - } + val optendSystime = endSystime.get() + put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) + } if (minSystime.isPresent) { - val optminSystime = minSystime.get() - put(ContextSpecificTag(TAG_MIN_SYSTIME), optminSystime) - } + val optminSystime = minSystime.get() + put(ContextSpecificTag(TAG_MIN_SYSTIME), optminSystime) + } if (maxSystime.isPresent) { - val optmaxSystime = maxSystime.get() - put(ContextSpecificTag(TAG_MAX_SYSTIME), optmaxSystime) - } + val optmaxSystime = maxSystime.get() + put(ContextSpecificTag(TAG_MAX_SYSTIME), optmaxSystime) + } endStructure() } } @@ -109,55 +107,78 @@ class ElectricalPowerMeasurementClusterMeasurementRangeStruct ( private const val TAG_MIN_SYSTIME = 9 private const val TAG_MAX_SYSTIME = 10 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalPowerMeasurementClusterMeasurementRangeStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementRangeStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUInt(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val min = tlvReader.getLong(ContextSpecificTag(TAG_MIN)) val max = tlvReader.getLong(ContextSpecificTag(TAG_MAX)) - val startTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) - } else { - Optional.empty() - } - val endTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) - } else { - Optional.empty() - } - val minTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_TIMESTAMP))) - } else { - Optional.empty() - } - val maxTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_TIMESTAMP))) - } else { - Optional.empty() - } - val startSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) - } else { - Optional.empty() - } - val endSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) - } else { - Optional.empty() - } - val minSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_SYSTIME))) - } else { - Optional.empty() - } - val maxSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_SYSTIME))) - } else { - Optional.empty() - } - + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val minTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_TIMESTAMP))) + } else { + Optional.empty() + } + val maxTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + val minSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_SYSTIME))) + } else { + Optional.empty() + } + val maxSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_SYSTIME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalPowerMeasurementClusterMeasurementRangeStruct(measurementType, min, max, startTimestamp, endTimestamp, minTimestamp, maxTimestamp, startSystime, endSystime, minSystime, maxSystime) + return ElectricalPowerMeasurementClusterMeasurementRangeStruct( + measurementType, + min, + max, + startTimestamp, + endTimestamp, + minTimestamp, + maxTimestamp, + startSystime, + endSystime, + minSystime, + maxSystime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt index 1fe6ccedd3ae38..bddc2563640620 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterChargingTargetScheduleStruct ( - val dayOfWeekForSequence: UInt, - val chargingTargets: List) { - override fun toString(): String = buildString { +class EnergyEvseClusterChargingTargetScheduleStruct( + val dayOfWeekForSequence: UInt, + val chargingTargets: List +) { + override fun toString(): String = buildString { append("EnergyEvseClusterChargingTargetScheduleStruct {\n") append("\tdayOfWeekForSequence : $dayOfWeekForSequence\n") append("\tchargingTargets : $chargingTargets\n") @@ -53,17 +51,18 @@ class EnergyEvseClusterChargingTargetScheduleStruct ( private const val TAG_DAY_OF_WEEK_FOR_SEQUENCE = 0 private const val TAG_CHARGING_TARGETS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterChargingTargetScheduleStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct { tlvReader.enterStructure(tlvTag) val dayOfWeekForSequence = tlvReader.getUInt(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) - val chargingTargets = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val chargingTargets = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return EnergyEvseClusterChargingTargetScheduleStruct(dayOfWeekForSequence, chargingTargets) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt index 1f87d383888f87..9e859dbdf40e53 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterChargingTargetStruct ( - val targetTimeMinutesPastMidnight: UInt, - val targetSoC: Optional, - val addedEnergy: Optional) { - override fun toString(): String = buildString { +class EnergyEvseClusterChargingTargetStruct( + val targetTimeMinutesPastMidnight: UInt, + val targetSoC: Optional, + val addedEnergy: Optional +) { + override fun toString(): String = buildString { append("EnergyEvseClusterChargingTargetStruct {\n") append("\ttargetTimeMinutesPastMidnight : $targetTimeMinutesPastMidnight\n") append("\ttargetSoC : $targetSoC\n") @@ -43,13 +41,13 @@ class EnergyEvseClusterChargingTargetStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT), targetTimeMinutesPastMidnight) if (targetSoC.isPresent) { - val opttargetSoC = targetSoC.get() - put(ContextSpecificTag(TAG_TARGET_SO_C), opttargetSoC) - } + val opttargetSoC = targetSoC.get() + put(ContextSpecificTag(TAG_TARGET_SO_C), opttargetSoC) + } if (addedEnergy.isPresent) { - val optaddedEnergy = addedEnergy.get() - put(ContextSpecificTag(TAG_ADDED_ENERGY), optaddedEnergy) - } + val optaddedEnergy = addedEnergy.get() + put(ContextSpecificTag(TAG_ADDED_ENERGY), optaddedEnergy) + } endStructure() } } @@ -59,23 +57,30 @@ class EnergyEvseClusterChargingTargetStruct ( private const val TAG_TARGET_SO_C = 1 private const val TAG_ADDED_ENERGY = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterChargingTargetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetStruct { tlvReader.enterStructure(tlvTag) - val targetTimeMinutesPastMidnight = tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) - val targetSoC = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SO_C))) - } else { - Optional.empty() - } - val addedEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) - } else { - Optional.empty() - } - + val targetTimeMinutesPastMidnight = + tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) + val targetSoC = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SO_C))) + } else { + Optional.empty() + } + val addedEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterChargingTargetStruct(targetTimeMinutesPastMidnight, targetSoC, addedEnergy) + return EnergyEvseClusterChargingTargetStruct( + targetTimeMinutesPastMidnight, + targetSoC, + addedEnergy + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt index 266d62d59d595f..762598ee0f78c9 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class EnergyEvseModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("EnergyEvseModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class EnergyEvseModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return EnergyEvseModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeTagStruct.kt index eeddfd3a6f0736..44073906d8afdc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class EnergyEvseModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("EnergyEvseModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class EnergyEvseModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class EnergyEvseModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return EnergyEvseModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt index 677ef98e62f19c..75f77558f0e982 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyPreferenceClusterBalanceStruct ( - val step: UInt, - val label: Optional) { - override fun toString(): String = buildString { +class EnergyPreferenceClusterBalanceStruct(val step: UInt, val label: Optional) { + override fun toString(): String = buildString { append("EnergyPreferenceClusterBalanceStruct {\n") append("\tstep : $step\n") append("\tlabel : $label\n") @@ -41,9 +36,9 @@ class EnergyPreferenceClusterBalanceStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_STEP), step) if (label.isPresent) { - val optlabel = label.get() - put(ContextSpecificTag(TAG_LABEL), optlabel) - } + val optlabel = label.get() + put(ContextSpecificTag(TAG_LABEL), optlabel) + } endStructure() } } @@ -52,15 +47,16 @@ class EnergyPreferenceClusterBalanceStruct ( private const val TAG_STEP = 0 private const val TAG_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyPreferenceClusterBalanceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyPreferenceClusterBalanceStruct { tlvReader.enterStructure(tlvTag) val step = tlvReader.getUInt(ContextSpecificTag(TAG_STEP)) - val label = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - + val label = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return EnergyPreferenceClusterBalanceStruct(step, label) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt index 3ca4e99e618df8..258f336d66e50b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class FixedLabelClusterLabelStruct ( - val label: String, - val value: String) { - override fun toString(): String = buildString { +class FixedLabelClusterLabelStruct(val label: String, val value: String) { + override fun toString(): String = buildString { append("FixedLabelClusterLabelStruct {\n") append("\tlabel : $label\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class FixedLabelClusterLabelStruct ( private const val TAG_LABEL = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : FixedLabelClusterLabelStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): FixedLabelClusterLabelStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return FixedLabelClusterLabelStruct(label, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt index 6ea28a8fbf75da..eb37145e36f754 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralCommissioningClusterBasicCommissioningInfo ( - val failSafeExpiryLengthSeconds: UInt, - val maxCumulativeFailsafeSeconds: UInt) { - override fun toString(): String = buildString { +class GeneralCommissioningClusterBasicCommissioningInfo( + val failSafeExpiryLengthSeconds: UInt, + val maxCumulativeFailsafeSeconds: UInt +) { + override fun toString(): String = buildString { append("GeneralCommissioningClusterBasicCommissioningInfo {\n") append("\tfailSafeExpiryLengthSeconds : $failSafeExpiryLengthSeconds\n") append("\tmaxCumulativeFailsafeSeconds : $maxCumulativeFailsafeSeconds\n") @@ -49,14 +46,22 @@ class GeneralCommissioningClusterBasicCommissioningInfo ( private const val TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS = 0 private const val TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralCommissioningClusterBasicCommissioningInfo { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralCommissioningClusterBasicCommissioningInfo { tlvReader.enterStructure(tlvTag) - val failSafeExpiryLengthSeconds = tlvReader.getUInt(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) - val maxCumulativeFailsafeSeconds = tlvReader.getUInt(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) - + val failSafeExpiryLengthSeconds = + tlvReader.getUInt(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) + val maxCumulativeFailsafeSeconds = + tlvReader.getUInt(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) + tlvReader.exitContainer() - return GeneralCommissioningClusterBasicCommissioningInfo(failSafeExpiryLengthSeconds, maxCumulativeFailsafeSeconds) + return GeneralCommissioningClusterBasicCommissioningInfo( + failSafeExpiryLengthSeconds, + maxCumulativeFailsafeSeconds + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt index 7656b672bd9058..3f310757c51e6f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt @@ -20,22 +20,20 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterNetworkInterface ( - val name: String, - val isOperational: Boolean, - val offPremiseServicesReachableIPv4: Boolean?, - val offPremiseServicesReachableIPv6: Boolean?, - val hardwareAddress: ByteArray, - val IPv4Addresses: List, - val IPv6Addresses: List, - val type: UInt) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterNetworkInterface( + val name: String, + val isOperational: Boolean, + val offPremiseServicesReachableIPv4: Boolean?, + val offPremiseServicesReachableIPv6: Boolean?, + val hardwareAddress: ByteArray, + val IPv4Addresses: List, + val IPv6Addresses: List, + val type: UInt +) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterNetworkInterface {\n") append("\tname : $name\n") append("\tisOperational : $isOperational\n") @@ -54,15 +52,21 @@ class GeneralDiagnosticsClusterNetworkInterface ( put(ContextSpecificTag(TAG_NAME), name) put(ContextSpecificTag(TAG_IS_OPERATIONAL), isOperational) if (offPremiseServicesReachableIPv4 != null) { - put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), offPremiseServicesReachableIPv4) - } else { - putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - } + put( + ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), + offPremiseServicesReachableIPv4 + ) + } else { + putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + } if (offPremiseServicesReachableIPv6 != null) { - put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), offPremiseServicesReachableIPv6) - } else { - putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - } + put( + ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), + offPremiseServicesReachableIPv6 + ) + } else { + putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + } put(ContextSpecificTag(TAG_HARDWARE_ADDRESS), hardwareAddress) startArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) for (item in IPv4Addresses.iterator()) { @@ -89,42 +93,55 @@ class GeneralDiagnosticsClusterNetworkInterface ( private const val TAG_I_PV6_ADDRESSES = 6 private const val TAG_TYPE = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterNetworkInterface { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterNetworkInterface { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val isOperational = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_OPERATIONAL)) - val offPremiseServicesReachableIPv4 = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - null - } - val offPremiseServicesReachableIPv6 = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - null - } + val offPremiseServicesReachableIPv4 = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + null + } + val offPremiseServicesReachableIPv6 = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + null + } val hardwareAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_HARDWARE_ADDRESS)) - val IPv4Addresses = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val IPv6Addresses = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val IPv4Addresses = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val IPv6Addresses = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) - + tlvReader.exitContainer() - return GeneralDiagnosticsClusterNetworkInterface(name, isOperational, offPremiseServicesReachableIPv4, offPremiseServicesReachableIPv6, hardwareAddress, IPv4Addresses, IPv6Addresses, type) + return GeneralDiagnosticsClusterNetworkInterface( + name, + isOperational, + offPremiseServicesReachableIPv4, + offPremiseServicesReachableIPv6, + hardwareAddress, + IPv4Addresses, + IPv6Addresses, + type + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt index 72cf67168df8e4..1549a376b4542a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt @@ -17,21 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GroupKeyManagementClusterGroupInfoMapStruct ( - val groupId: UInt, - val endpoints: List, - val groupName: Optional, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class GroupKeyManagementClusterGroupInfoMapStruct( + val groupId: UInt, + val endpoints: List, + val groupName: Optional, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("GroupKeyManagementClusterGroupInfoMapStruct {\n") append("\tgroupId : $groupId\n") append("\tendpoints : $endpoints\n") @@ -50,9 +49,9 @@ class GroupKeyManagementClusterGroupInfoMapStruct ( } endArray() if (groupName.isPresent) { - val optgroupName = groupName.get() - put(ContextSpecificTag(TAG_GROUP_NAME), optgroupName) - } + val optgroupName = groupName.get() + put(ContextSpecificTag(TAG_GROUP_NAME), optgroupName) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -64,23 +63,25 @@ class GroupKeyManagementClusterGroupInfoMapStruct ( private const val TAG_GROUP_NAME = 3 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GroupKeyManagementClusterGroupInfoMapStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupInfoMapStruct { tlvReader.enterStructure(tlvTag) val groupId = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_ID)) - val endpoints = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val groupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) - } else { - Optional.empty() - } + val endpoints = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val groupName = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupInfoMapStruct(groupId, endpoints, groupName, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt index 71d7c3ca4cb959..46f4656366bbc8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GroupKeyManagementClusterGroupKeyMapStruct ( - val groupId: UInt, - val groupKeySetID: UInt, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class GroupKeyManagementClusterGroupKeyMapStruct( + val groupId: UInt, + val groupKeySetID: UInt, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("GroupKeyManagementClusterGroupKeyMapStruct {\n") append("\tgroupId : $groupId\n") append("\tgroupKeySetID : $groupKeySetID\n") @@ -53,12 +50,12 @@ class GroupKeyManagementClusterGroupKeyMapStruct ( private const val TAG_GROUP_KEY_SET_I_D = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GroupKeyManagementClusterGroupKeyMapStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupKeyMapStruct { tlvReader.enterStructure(tlvTag) val groupId = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_ID)) val groupKeySetID = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupKeyMapStruct(groupId, groupKeySetID, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt index 2eee6ef47d3353..4d995ac2974023 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt @@ -17,25 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GroupKeyManagementClusterGroupKeySetStruct ( - val groupKeySetID: UInt, - val groupKeySecurityPolicy: UInt, - val epochKey0: ByteArray?, - val epochStartTime0: ULong?, - val epochKey1: ByteArray?, - val epochStartTime1: ULong?, - val epochKey2: ByteArray?, - val epochStartTime2: ULong?) { - override fun toString(): String = buildString { +class GroupKeyManagementClusterGroupKeySetStruct( + val groupKeySetID: UInt, + val groupKeySecurityPolicy: UInt, + val epochKey0: ByteArray?, + val epochStartTime0: ULong?, + val epochKey1: ByteArray?, + val epochStartTime1: ULong?, + val epochKey2: ByteArray?, + val epochStartTime2: ULong? +) { + override fun toString(): String = buildString { append("GroupKeyManagementClusterGroupKeySetStruct {\n") append("\tgroupKeySetID : $groupKeySetID\n") append("\tgroupKeySecurityPolicy : $groupKeySecurityPolicy\n") @@ -54,35 +51,35 @@ class GroupKeyManagementClusterGroupKeySetStruct ( put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D), groupKeySetID) put(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY), groupKeySecurityPolicy) if (epochKey0 != null) { - put(ContextSpecificTag(TAG_EPOCH_KEY0), epochKey0) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_KEY0)) - } + put(ContextSpecificTag(TAG_EPOCH_KEY0), epochKey0) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_KEY0)) + } if (epochStartTime0 != null) { - put(ContextSpecificTag(TAG_EPOCH_START_TIME0), epochStartTime0) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - } + put(ContextSpecificTag(TAG_EPOCH_START_TIME0), epochStartTime0) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + } if (epochKey1 != null) { - put(ContextSpecificTag(TAG_EPOCH_KEY1), epochKey1) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_KEY1)) - } + put(ContextSpecificTag(TAG_EPOCH_KEY1), epochKey1) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_KEY1)) + } if (epochStartTime1 != null) { - put(ContextSpecificTag(TAG_EPOCH_START_TIME1), epochStartTime1) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - } + put(ContextSpecificTag(TAG_EPOCH_START_TIME1), epochStartTime1) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + } if (epochKey2 != null) { - put(ContextSpecificTag(TAG_EPOCH_KEY2), epochKey2) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_KEY2)) - } + put(ContextSpecificTag(TAG_EPOCH_KEY2), epochKey2) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_KEY2)) + } if (epochStartTime2 != null) { - put(ContextSpecificTag(TAG_EPOCH_START_TIME2), epochStartTime2) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - } + put(ContextSpecificTag(TAG_EPOCH_START_TIME2), epochStartTime2) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + } endStructure() } } @@ -97,50 +94,66 @@ class GroupKeyManagementClusterGroupKeySetStruct ( private const val TAG_EPOCH_KEY2 = 6 private const val TAG_EPOCH_START_TIME2 = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GroupKeyManagementClusterGroupKeySetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupKeySetStruct { tlvReader.enterStructure(tlvTag) val groupKeySetID = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) - val groupKeySecurityPolicy = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) - val epochKey0 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) - null - } - val epochStartTime0 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - null - } - val epochKey1 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) - null - } - val epochStartTime1 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - null - } - val epochKey2 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) - null - } - val epochStartTime2 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - null - } - + val groupKeySecurityPolicy = + tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) + val epochKey0 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) + null + } + val epochStartTime0 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + null + } + val epochKey1 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) + null + } + val epochStartTime1 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + null + } + val epochKey2 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) + null + } + val epochStartTime2 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + null + } + tlvReader.exitContainer() - return GroupKeyManagementClusterGroupKeySetStruct(groupKeySetID, groupKeySecurityPolicy, epochKey0, epochStartTime0, epochKey1, epochStartTime1, epochKey2, epochStartTime2) + return GroupKeyManagementClusterGroupKeySetStruct( + groupKeySetID, + groupKeySecurityPolicy, + epochKey0, + epochStartTime0, + epochKey1, + epochStartTime1, + epochKey2, + epochStartTime2 + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt index a5e79f7e076234..b36468116ac1dd 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class HepaFilterMonitoringClusterReplacementProductStruct ( - val productIdentifierType: UInt, - val productIdentifierValue: String) { - override fun toString(): String = buildString { +class HepaFilterMonitoringClusterReplacementProductStruct( + val productIdentifierType: UInt, + val productIdentifierValue: String +) { + override fun toString(): String = buildString { append("HepaFilterMonitoringClusterReplacementProductStruct {\n") append("\tproductIdentifierType : $productIdentifierType\n") append("\tproductIdentifierValue : $productIdentifierValue\n") @@ -49,14 +46,21 @@ class HepaFilterMonitoringClusterReplacementProductStruct ( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : HepaFilterMonitoringClusterReplacementProductStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): HepaFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) val productIdentifierType = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierValue = + tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return HepaFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) + return HepaFilterMonitoringClusterReplacementProductStruct( + productIdentifierType, + productIdentifierValue + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt index 85f126f794d4cf..486bb906e79940 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class IcdManagementClusterMonitoringRegistrationStruct ( - val checkInNodeID: ULong, - val monitoredSubject: ULong, - val clientType: UInt, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class IcdManagementClusterMonitoringRegistrationStruct( + val checkInNodeID: ULong, + val monitoredSubject: ULong, + val clientType: UInt, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("IcdManagementClusterMonitoringRegistrationStruct {\n") append("\tcheckInNodeID : $checkInNodeID\n") append("\tmonitoredSubject : $monitoredSubject\n") @@ -57,16 +54,24 @@ class IcdManagementClusterMonitoringRegistrationStruct ( private const val TAG_CLIENT_TYPE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : IcdManagementClusterMonitoringRegistrationStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): IcdManagementClusterMonitoringRegistrationStruct { tlvReader.enterStructure(tlvTag) val checkInNodeID = tlvReader.getULong(ContextSpecificTag(TAG_CHECK_IN_NODE_I_D)) val monitoredSubject = tlvReader.getULong(ContextSpecificTag(TAG_MONITORED_SUBJECT)) val clientType = tlvReader.getUInt(ContextSpecificTag(TAG_CLIENT_TYPE)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return IcdManagementClusterMonitoringRegistrationStruct(checkInNodeID, monitoredSubject, clientType, fabricIndex) + return IcdManagementClusterMonitoringRegistrationStruct( + checkInNodeID, + monitoredSubject, + clientType, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt index 539ddd1fe657ec..f6ca291e0bb46e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class LaundryWasherModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class LaundryWasherModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("LaundryWasherModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class LaundryWasherModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : LaundryWasherModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): LaundryWasherModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return LaundryWasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt index f5e971f19259ee..09c2915126efd6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class LaundryWasherModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("LaundryWasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class LaundryWasherModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class LaundryWasherModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : LaundryWasherModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): LaundryWasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return LaundryWasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt index a1e171a4805248..b2b26104143da8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaInputClusterInputInfoStruct ( - val index: UInt, - val inputType: UInt, - val name: String, - val description: String) { - override fun toString(): String = buildString { +class MediaInputClusterInputInfoStruct( + val index: UInt, + val inputType: UInt, + val name: String, + val description: String +) { + override fun toString(): String = buildString { append("MediaInputClusterInputInfoStruct {\n") append("\tindex : $index\n") append("\tinputType : $inputType\n") @@ -57,13 +54,13 @@ class MediaInputClusterInputInfoStruct ( private const val TAG_NAME = 2 private const val TAG_DESCRIPTION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaInputClusterInputInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaInputClusterInputInfoStruct { tlvReader.enterStructure(tlvTag) val index = tlvReader.getUInt(ContextSpecificTag(TAG_INDEX)) val inputType = tlvReader.getUInt(ContextSpecificTag(TAG_INPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val description = tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION)) - + tlvReader.exitContainer() return MediaInputClusterInputInfoStruct(index, inputType, name, description) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt index a41c94eb25f23b..c58c381f8d6e14 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaPlaybackClusterPlaybackPositionStruct ( - val updatedAt: ULong, - val position: ULong?) { - override fun toString(): String = buildString { +class MediaPlaybackClusterPlaybackPositionStruct(val updatedAt: ULong, val position: ULong?) { + override fun toString(): String = buildString { append("MediaPlaybackClusterPlaybackPositionStruct {\n") append("\tupdatedAt : $updatedAt\n") append("\tposition : $position\n") @@ -41,10 +35,10 @@ class MediaPlaybackClusterPlaybackPositionStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_UPDATED_AT), updatedAt) if (position != null) { - put(ContextSpecificTag(TAG_POSITION), position) - } else { - putNull(ContextSpecificTag(TAG_POSITION)) - } + put(ContextSpecificTag(TAG_POSITION), position) + } else { + putNull(ContextSpecificTag(TAG_POSITION)) + } endStructure() } } @@ -53,16 +47,17 @@ class MediaPlaybackClusterPlaybackPositionStruct ( private const val TAG_UPDATED_AT = 0 private const val TAG_POSITION = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterPlaybackPositionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterPlaybackPositionStruct { tlvReader.enterStructure(tlvTag) val updatedAt = tlvReader.getULong(ContextSpecificTag(TAG_UPDATED_AT)) - val position = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) - null - } - + val position = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterPlaybackPositionStruct(updatedAt, position) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt index 85afda84daca8d..1b991a4a051864 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaPlaybackClusterTrackAttributesStruct ( - val languageCode: String, - val displayName: Optional?) { - override fun toString(): String = buildString { +class MediaPlaybackClusterTrackAttributesStruct( + val languageCode: String, + val displayName: Optional? +) { + override fun toString(): String = buildString { append("MediaPlaybackClusterTrackAttributesStruct {\n") append("\tlanguageCode : $languageCode\n") append("\tdisplayName : $displayName\n") @@ -41,13 +39,13 @@ class MediaPlaybackClusterTrackAttributesStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_LANGUAGE_CODE), languageCode) if (displayName != null) { - if (displayName.isPresent) { - val optdisplayName = displayName.get() - put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) - } - } else { - putNull(ContextSpecificTag(TAG_DISPLAY_NAME)) - } + if (displayName.isPresent) { + val optdisplayName = displayName.get() + put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) + } + } else { + putNull(ContextSpecificTag(TAG_DISPLAY_NAME)) + } endStructure() } } @@ -56,20 +54,21 @@ class MediaPlaybackClusterTrackAttributesStruct ( private const val TAG_LANGUAGE_CODE = 0 private const val TAG_DISPLAY_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterTrackAttributesStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackAttributesStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val displayName = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) - null - } - + val displayName = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackAttributesStruct(languageCode, displayName) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt index cca4fa751f8d8d..087bc437a2a754 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaPlaybackClusterTrackStruct ( - val id: String, - val trackAttributes: MediaPlaybackClusterTrackAttributesStruct?) { - override fun toString(): String = buildString { +class MediaPlaybackClusterTrackStruct( + val id: String, + val trackAttributes: MediaPlaybackClusterTrackAttributesStruct? +) { + override fun toString(): String = buildString { append("MediaPlaybackClusterTrackStruct {\n") append("\tid : $id\n") append("\ttrackAttributes : $trackAttributes\n") @@ -41,10 +38,10 @@ class MediaPlaybackClusterTrackStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ID), id) if (trackAttributes != null) { - trackAttributes.toTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), this) - } else { - putNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) - } + trackAttributes.toTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), this) + } else { + putNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) + } endStructure() } } @@ -53,16 +50,20 @@ class MediaPlaybackClusterTrackStruct ( private const val TAG_ID = 0 private const val TAG_TRACK_ATTRIBUTES = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterTrackStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getString(ContextSpecificTag(TAG_ID)) - val trackAttributes = if (!tlvReader.isNull()) { - MediaPlaybackClusterTrackAttributesStruct.fromTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) - null - } - + val trackAttributes = + if (!tlvReader.isNull()) { + MediaPlaybackClusterTrackAttributesStruct.fromTlv( + ContextSpecificTag(TAG_TRACK_ATTRIBUTES), + tlvReader + ) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackStruct(id, trackAttributes) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MessagesClusterMessageResponseOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MessagesClusterMessageResponseOptionStruct.kt index cad8930f67659d..5a151b76c6954a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MessagesClusterMessageResponseOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MessagesClusterMessageResponseOptionStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MessagesClusterMessageResponseOptionStruct ( - val messageResponseID: Optional, - val label: Optional) { - override fun toString(): String = buildString { +class MessagesClusterMessageResponseOptionStruct( + val messageResponseID: Optional, + val label: Optional +) { + override fun toString(): String = buildString { append("MessagesClusterMessageResponseOptionStruct {\n") append("\tmessageResponseID : $messageResponseID\n") append("\tlabel : $label\n") @@ -40,13 +38,13 @@ class MessagesClusterMessageResponseOptionStruct ( tlvWriter.apply { startStructure(tlvTag) if (messageResponseID.isPresent) { - val optmessageResponseID = messageResponseID.get() - put(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D), optmessageResponseID) - } + val optmessageResponseID = messageResponseID.get() + put(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D), optmessageResponseID) + } if (label.isPresent) { - val optlabel = label.get() - put(ContextSpecificTag(TAG_LABEL), optlabel) - } + val optlabel = label.get() + put(ContextSpecificTag(TAG_LABEL), optlabel) + } endStructure() } } @@ -55,19 +53,21 @@ class MessagesClusterMessageResponseOptionStruct ( private const val TAG_MESSAGE_RESPONSE_I_D = 0 private const val TAG_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MessagesClusterMessageResponseOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessageResponseOptionStruct { tlvReader.enterStructure(tlvTag) - val messageResponseID = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D))) - } else { - Optional.empty() - } - val label = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - + val messageResponseID = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D))) + } else { + Optional.empty() + } + val label = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return MessagesClusterMessageResponseOptionStruct(messageResponseID, label) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MessagesClusterMessageStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MessagesClusterMessageStruct.kt index 9f323d4acaf6d3..03a544caf41c32 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MessagesClusterMessageStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MessagesClusterMessageStruct.kt @@ -17,24 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MessagesClusterMessageStruct ( - val messageID: ByteArray, - val priority: UInt, - val messageControl: UInt, - val startTime: ULong?, - val duration: ULong?, - val messageText: String, - val responses: Optional>) { - override fun toString(): String = buildString { +class MessagesClusterMessageStruct( + val messageID: ByteArray, + val priority: UInt, + val messageControl: UInt, + val startTime: ULong?, + val duration: ULong?, + val messageText: String, + val responses: Optional> +) { + override fun toString(): String = buildString { append("MessagesClusterMessageStruct {\n") append("\tmessageID : $messageID\n") append("\tpriority : $priority\n") @@ -53,24 +52,24 @@ class MessagesClusterMessageStruct ( put(ContextSpecificTag(TAG_PRIORITY), priority) put(ContextSpecificTag(TAG_MESSAGE_CONTROL), messageControl) if (startTime != null) { - put(ContextSpecificTag(TAG_START_TIME), startTime) - } else { - putNull(ContextSpecificTag(TAG_START_TIME)) - } + put(ContextSpecificTag(TAG_START_TIME), startTime) + } else { + putNull(ContextSpecificTag(TAG_START_TIME)) + } if (duration != null) { - put(ContextSpecificTag(TAG_DURATION), duration) - } else { - putNull(ContextSpecificTag(TAG_DURATION)) - } + put(ContextSpecificTag(TAG_DURATION), duration) + } else { + putNull(ContextSpecificTag(TAG_DURATION)) + } put(ContextSpecificTag(TAG_MESSAGE_TEXT), messageText) if (responses.isPresent) { - val optresponses = responses.get() - startArray(ContextSpecificTag(TAG_RESPONSES)) - for (item in optresponses.iterator()) { - item.toTlv(AnonymousTag, this) + val optresponses = responses.get() + startArray(ContextSpecificTag(TAG_RESPONSES)) + for (item in optresponses.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } endStructure() } } @@ -84,39 +83,52 @@ class MessagesClusterMessageStruct ( private const val TAG_MESSAGE_TEXT = 5 private const val TAG_RESPONSES = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MessagesClusterMessageStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessageStruct { tlvReader.enterStructure(tlvTag) val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D)) val priority = tlvReader.getUInt(ContextSpecificTag(TAG_PRIORITY)) val messageControl = tlvReader.getUInt(ContextSpecificTag(TAG_MESSAGE_CONTROL)) - val startTime = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val duration = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DURATION)) - null - } + val startTime = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) + null + } + val duration = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DURATION)) + null + } val messageText = tlvReader.getString(ContextSpecificTag(TAG_MESSAGE_TEXT)) - val responses = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSES))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RESPONSES)) - while(!tlvReader.isEndOfContainer()) { - add(MessagesClusterMessageResponseOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val responses = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSES))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_RESPONSES)) + while (!tlvReader.isEndOfContainer()) { + add(MessagesClusterMessageResponseOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return MessagesClusterMessageStruct(messageID, priority, messageControl, startTime, duration, messageText, responses) + return MessagesClusterMessageStruct( + messageID, + priority, + messageControl, + startTime, + duration, + messageText, + responses + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt index 504a72e24e3598..69caf35509d049 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MicrowaveOvenModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class MicrowaveOvenModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class MicrowaveOvenModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MicrowaveOvenModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MicrowaveOvenModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt index 4459562dcadcf3..bf9800a012de5f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MicrowaveOvenModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class MicrowaveOvenModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class MicrowaveOvenModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MicrowaveOvenModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MicrowaveOvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt index 6613c8f6988cc6..fb74943fcd20b0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ModeSelectClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val semanticTags: List) { - override fun toString(): String = buildString { +class ModeSelectClusterModeOptionStruct( + val label: String, + val mode: UInt, + val semanticTags: List +) { + override fun toString(): String = buildString { append("ModeSelectClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class ModeSelectClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_SEMANTIC_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ModeSelectClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ModeSelectClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val semanticTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val semanticTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ModeSelectClusterModeOptionStruct(label, mode, semanticTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt index 2b501b089a5d8e..ca14c2ebd4d8dc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ModeSelectClusterSemanticTagStruct ( - val mfgCode: UInt, - val value: UInt) { - override fun toString(): String = buildString { +class ModeSelectClusterSemanticTagStruct(val mfgCode: UInt, val value: UInt) { + override fun toString(): String = buildString { append("ModeSelectClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class ModeSelectClusterSemanticTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ModeSelectClusterSemanticTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ModeSelectClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) val mfgCode = tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE)) val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ModeSelectClusterSemanticTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt index 78e54129ba293a..82f98aeb677204 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class NetworkCommissioningClusterNetworkInfoStruct ( - val networkID: ByteArray, - val connected: Boolean, - val networkIdentifier: Optional?, - val clientIdentifier: Optional?) { - override fun toString(): String = buildString { +class NetworkCommissioningClusterNetworkInfoStruct( + val networkID: ByteArray, + val connected: Boolean, + val networkIdentifier: Optional?, + val clientIdentifier: Optional? +) { + override fun toString(): String = buildString { append("NetworkCommissioningClusterNetworkInfoStruct {\n") append("\tnetworkID : $networkID\n") append("\tconnected : $connected\n") @@ -46,21 +44,21 @@ class NetworkCommissioningClusterNetworkInfoStruct ( put(ContextSpecificTag(TAG_NETWORK_I_D), networkID) put(ContextSpecificTag(TAG_CONNECTED), connected) if (networkIdentifier != null) { - if (networkIdentifier.isPresent) { - val optnetworkIdentifier = networkIdentifier.get() - put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) - } - } else { - putNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) - } + if (networkIdentifier.isPresent) { + val optnetworkIdentifier = networkIdentifier.get() + put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) + } + } else { + putNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) + } if (clientIdentifier != null) { - if (clientIdentifier.isPresent) { - val optclientIdentifier = clientIdentifier.get() - put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) - } - } else { - putNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) - } + if (clientIdentifier.isPresent) { + val optclientIdentifier = clientIdentifier.get() + put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) + } + } else { + putNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) + } endStructure() } } @@ -71,34 +69,41 @@ class NetworkCommissioningClusterNetworkInfoStruct ( private const val TAG_NETWORK_IDENTIFIER = 2 private const val TAG_CLIENT_IDENTIFIER = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : NetworkCommissioningClusterNetworkInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): NetworkCommissioningClusterNetworkInfoStruct { tlvReader.enterStructure(tlvTag) val networkID = tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_I_D)) val connected = tlvReader.getBoolean(ContextSpecificTag(TAG_CONNECTED)) - val networkIdentifier = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) - null - } - val clientIdentifier = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) - null - } - + val networkIdentifier = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) + null + } + val clientIdentifier = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) + null + } + tlvReader.exitContainer() - return NetworkCommissioningClusterNetworkInfoStruct(networkID, connected, networkIdentifier, clientIdentifier) + return NetworkCommissioningClusterNetworkInfoStruct( + networkID, + connected, + networkIdentifier, + clientIdentifier + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt index 01d987d0125f0f..c72319998ba002 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt @@ -17,25 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class NetworkCommissioningClusterThreadInterfaceScanResultStruct ( - val panId: UInt, - val extendedPanId: ULong, - val networkName: String, - val channel: UInt, - val version: UInt, - val extendedAddress: ByteArray, - val rssi: Int, - val lqi: UInt) { - override fun toString(): String = buildString { +class NetworkCommissioningClusterThreadInterfaceScanResultStruct( + val panId: UInt, + val extendedPanId: ULong, + val networkName: String, + val channel: UInt, + val version: UInt, + val extendedAddress: ByteArray, + val rssi: Int, + val lqi: UInt +) { + override fun toString(): String = buildString { append("NetworkCommissioningClusterThreadInterfaceScanResultStruct {\n") append("\tpanId : $panId\n") append("\textendedPanId : $extendedPanId\n") @@ -73,7 +70,10 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct ( private const val TAG_RSSI = 6 private const val TAG_LQI = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : NetworkCommissioningClusterThreadInterfaceScanResultStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): NetworkCommissioningClusterThreadInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val panId = tlvReader.getUInt(ContextSpecificTag(TAG_PAN_ID)) val extendedPanId = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_ID)) @@ -83,10 +83,19 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct ( val extendedAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_EXTENDED_ADDRESS)) val rssi = tlvReader.getInt(ContextSpecificTag(TAG_RSSI)) val lqi = tlvReader.getUInt(ContextSpecificTag(TAG_LQI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterThreadInterfaceScanResultStruct(panId, extendedPanId, networkName, channel, version, extendedAddress, rssi, lqi) + return NetworkCommissioningClusterThreadInterfaceScanResultStruct( + panId, + extendedPanId, + networkName, + channel, + version, + extendedAddress, + rssi, + lqi + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt index 8bdbd11bbc322c..e3e4ef10cbce76 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt @@ -17,23 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class NetworkCommissioningClusterWiFiInterfaceScanResultStruct ( - val security: UInt, - val ssid: ByteArray, - val bssid: ByteArray, - val channel: UInt, - val wiFiBand: UInt, - val rssi: Int) { - override fun toString(): String = buildString { +class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( + val security: UInt, + val ssid: ByteArray, + val bssid: ByteArray, + val channel: UInt, + val wiFiBand: UInt, + val rssi: Int +) { + override fun toString(): String = buildString { append("NetworkCommissioningClusterWiFiInterfaceScanResultStruct {\n") append("\tsecurity : $security\n") append("\tssid : $ssid\n") @@ -65,7 +62,10 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct ( private const val TAG_WI_FI_BAND = 4 private const val TAG_RSSI = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : NetworkCommissioningClusterWiFiInterfaceScanResultStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val security = tlvReader.getUInt(ContextSpecificTag(TAG_SECURITY)) val ssid = tlvReader.getByteArray(ContextSpecificTag(TAG_SSID)) @@ -73,10 +73,17 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct ( val channel = tlvReader.getUInt(ContextSpecificTag(TAG_CHANNEL)) val wiFiBand = tlvReader.getUInt(ContextSpecificTag(TAG_WI_FI_BAND)) val rssi = tlvReader.getInt(ContextSpecificTag(TAG_RSSI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterWiFiInterfaceScanResultStruct(security, ssid, bssid, channel, wiFiBand, rssi) + return NetworkCommissioningClusterWiFiInterfaceScanResultStruct( + security, + ssid, + bssid, + channel, + wiFiBand, + rssi + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt index de9d80b7482140..a1e736d1b0407c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt @@ -17,23 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalCredentialsClusterFabricDescriptorStruct ( - val rootPublicKey: ByteArray, - val vendorID: UInt, - val fabricID: ULong, - val nodeID: ULong, - val label: String, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class OperationalCredentialsClusterFabricDescriptorStruct( + val rootPublicKey: ByteArray, + val vendorID: UInt, + val fabricID: ULong, + val nodeID: ULong, + val label: String, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("OperationalCredentialsClusterFabricDescriptorStruct {\n") append("\trootPublicKey : $rootPublicKey\n") append("\tvendorID : $vendorID\n") @@ -65,7 +62,10 @@ class OperationalCredentialsClusterFabricDescriptorStruct ( private const val TAG_LABEL = 5 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalCredentialsClusterFabricDescriptorStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OperationalCredentialsClusterFabricDescriptorStruct { tlvReader.enterStructure(tlvTag) val rootPublicKey = tlvReader.getByteArray(ContextSpecificTag(TAG_ROOT_PUBLIC_KEY)) val vendorID = tlvReader.getUInt(ContextSpecificTag(TAG_VENDOR_I_D)) @@ -73,10 +73,17 @@ class OperationalCredentialsClusterFabricDescriptorStruct ( val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OperationalCredentialsClusterFabricDescriptorStruct(rootPublicKey, vendorID, fabricID, nodeID, label, fabricIndex) + return OperationalCredentialsClusterFabricDescriptorStruct( + rootPublicKey, + vendorID, + fabricID, + nodeID, + label, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt index 2013bec14e74b5..a45a68e28cf2f8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalCredentialsClusterNOCStruct ( - val noc: ByteArray, - val icac: ByteArray?, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class OperationalCredentialsClusterNOCStruct( + val noc: ByteArray, + val icac: ByteArray?, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("OperationalCredentialsClusterNOCStruct {\n") append("\tnoc : $noc\n") append("\ticac : $icac\n") @@ -43,10 +40,10 @@ class OperationalCredentialsClusterNOCStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_NOC), noc) if (icac != null) { - put(ContextSpecificTag(TAG_ICAC), icac) - } else { - putNull(ContextSpecificTag(TAG_ICAC)) - } + put(ContextSpecificTag(TAG_ICAC), icac) + } else { + putNull(ContextSpecificTag(TAG_ICAC)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -57,17 +54,18 @@ class OperationalCredentialsClusterNOCStruct ( private const val TAG_ICAC = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalCredentialsClusterNOCStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalCredentialsClusterNOCStruct { tlvReader.enterStructure(tlvTag) val noc = tlvReader.getByteArray(ContextSpecificTag(TAG_NOC)) - val icac = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) - null - } + val icac = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return OperationalCredentialsClusterNOCStruct(noc, icac, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt index 6078c84c862ae8..c41c0205d88d84 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalStateClusterErrorStateStruct ( - val errorStateID: UInt, - val errorStateLabel: Optional, - val errorStateDetails: Optional) { - override fun toString(): String = buildString { +class OperationalStateClusterErrorStateStruct( + val errorStateID: UInt, + val errorStateLabel: Optional, + val errorStateDetails: Optional +) { + override fun toString(): String = buildString { append("OperationalStateClusterErrorStateStruct {\n") append("\terrorStateID : $errorStateID\n") append("\terrorStateLabel : $errorStateLabel\n") @@ -43,13 +41,13 @@ class OperationalStateClusterErrorStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ERROR_STATE_I_D), errorStateID) if (errorStateLabel.isPresent) { - val opterrorStateLabel = errorStateLabel.get() - put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) - } + val opterrorStateLabel = errorStateLabel.get() + put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) + } if (errorStateDetails.isPresent) { - val opterrorStateDetails = errorStateDetails.get() - put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) - } + val opterrorStateDetails = errorStateDetails.get() + put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) + } endStructure() } } @@ -59,23 +57,29 @@ class OperationalStateClusterErrorStateStruct ( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterErrorStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return OperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt index e464504d71b4f1..3157b9c4b7dec2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalStateClusterOperationalStateStruct ( - val operationalStateID: UInt, - val operationalStateLabel: Optional) { - override fun toString(): String = buildString { +class OperationalStateClusterOperationalStateStruct( + val operationalStateID: UInt, + val operationalStateLabel: Optional +) { + override fun toString(): String = buildString { append("OperationalStateClusterOperationalStateStruct {\n") append("\toperationalStateID : $operationalStateID\n") append("\toperationalStateLabel : $operationalStateLabel\n") @@ -41,9 +39,9 @@ class OperationalStateClusterOperationalStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D), operationalStateID) if (operationalStateLabel.isPresent) { - val optoperationalStateLabel = operationalStateLabel.get() - put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) - } + val optoperationalStateLabel = operationalStateLabel.get() + put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) + } endStructure() } } @@ -52,18 +50,22 @@ class OperationalStateClusterOperationalStateStruct ( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationalStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return OperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt index 7f80ca90ed8c9f..abb8f952cfce50 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OtaSoftwareUpdateRequestorClusterProviderLocation ( - val providerNodeID: ULong, - val endpoint: UInt, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class OtaSoftwareUpdateRequestorClusterProviderLocation( + val providerNodeID: ULong, + val endpoint: UInt, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterProviderLocation {\n") append("\tproviderNodeID : $providerNodeID\n") append("\tendpoint : $endpoint\n") @@ -53,15 +50,22 @@ class OtaSoftwareUpdateRequestorClusterProviderLocation ( private const val TAG_ENDPOINT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterProviderLocation { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterProviderLocation { tlvReader.enterStructure(tlvTag) val providerNodeID = tlvReader.getULong(ContextSpecificTag(TAG_PROVIDER_NODE_I_D)) val endpoint = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterProviderLocation(providerNodeID, endpoint, fabricIndex) + return OtaSoftwareUpdateRequestorClusterProviderLocation( + providerNodeID, + endpoint, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt index 8844263c96a1ce..dff5c0684a1501 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenCavityOperationalStateClusterErrorStateStruct ( - val errorStateID: UInt, - val errorStateLabel: Optional, - val errorStateDetails: Optional) { - override fun toString(): String = buildString { +class OvenCavityOperationalStateClusterErrorStateStruct( + val errorStateID: UInt, + val errorStateLabel: Optional, + val errorStateDetails: Optional +) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterErrorStateStruct {\n") append("\terrorStateID : $errorStateID\n") append("\terrorStateLabel : $errorStateLabel\n") @@ -43,13 +41,13 @@ class OvenCavityOperationalStateClusterErrorStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ERROR_STATE_I_D), errorStateID) if (errorStateLabel.isPresent) { - val opterrorStateLabel = errorStateLabel.get() - put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) - } + val opterrorStateLabel = errorStateLabel.get() + put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) + } if (errorStateDetails.isPresent) { - val opterrorStateDetails = errorStateDetails.get() - put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) - } + val opterrorStateDetails = errorStateDetails.get() + put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) + } endStructure() } } @@ -59,23 +57,32 @@ class OvenCavityOperationalStateClusterErrorStateStruct ( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterErrorStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return OvenCavityOperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt index 6d815321e7cb46..1d32c7fe4a6af2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenCavityOperationalStateClusterOperationalStateStruct ( - val operationalStateID: UInt, - val operationalStateLabel: Optional) { - override fun toString(): String = buildString { +class OvenCavityOperationalStateClusterOperationalStateStruct( + val operationalStateID: UInt, + val operationalStateLabel: Optional +) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalStateStruct {\n") append("\toperationalStateID : $operationalStateID\n") append("\toperationalStateLabel : $operationalStateLabel\n") @@ -41,9 +39,9 @@ class OvenCavityOperationalStateClusterOperationalStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D), operationalStateID) if (operationalStateLabel.isPresent) { - val optoperationalStateLabel = operationalStateLabel.get() - put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) - } + val optoperationalStateLabel = operationalStateLabel.get() + put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) + } endStructure() } } @@ -52,18 +50,25 @@ class OvenCavityOperationalStateClusterOperationalStateStruct ( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationalStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return OvenCavityOperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt index 4698441672eae2..0df558d3935e26 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class OvenModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("OvenModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class OvenModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return OvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt index 9c204fa8ecb2ea..df0465b2c3055d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("OvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class OvenModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class OvenModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return OvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt index c24d47fe4b23ee..1d260017a0b722 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterBatChargeFaultChangeType ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterBatChargeFaultChangeType( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("PowerSourceClusterBatChargeFaultChangeType {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,25 @@ class PowerSourceClusterBatChargeFaultChangeType ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatChargeFaultChangeType { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt index 789a1f0a36c47c..07ed4351bcd3a1 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt @@ -20,16 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterBatFaultChangeType ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterBatFaultChangeType(val current: List, val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeType {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +52,25 @@ class PowerSourceClusterBatFaultChangeType ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatFaultChangeType { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt index 849c0b2edfc454..f0c80ef26ff5ad 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt @@ -20,16 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterWiredFaultChangeType ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterWiredFaultChangeType(val current: List, val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeType {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +52,25 @@ class PowerSourceClusterWiredFaultChangeType ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterWiredFaultChangeType { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt index 74809e3ae5215c..85b1d995d2fd76 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,21 +55,34 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add( + RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct(label, mode, modeTags) + return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( + label, + mode, + modeTags + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt index 0831587768d6a3..db10b1db8bab30 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( + val mfgCode: Optional, + val value: UInt +) { + override fun toString(): String = buildString { append("RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +38,9 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +50,19 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt index d4cf5dd09a6214..31f7b8adb6ac63 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcCleanModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class RvcCleanModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("RvcCleanModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class RvcCleanModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcCleanModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcCleanModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcCleanModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt index 7c293c839acb4f..a06d26774dacc6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcCleanModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("RvcCleanModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class RvcCleanModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class RvcCleanModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcCleanModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcCleanModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcCleanModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt index 15f9250edbe478..0f8daddb5212c3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcOperationalStateClusterErrorStateStruct ( - val errorStateID: UInt, - val errorStateLabel: Optional, - val errorStateDetails: Optional) { - override fun toString(): String = buildString { +class RvcOperationalStateClusterErrorStateStruct( + val errorStateID: UInt, + val errorStateLabel: Optional, + val errorStateDetails: Optional +) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterErrorStateStruct {\n") append("\terrorStateID : $errorStateID\n") append("\terrorStateLabel : $errorStateLabel\n") @@ -43,13 +41,13 @@ class RvcOperationalStateClusterErrorStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ERROR_STATE_I_D), errorStateID) if (errorStateLabel.isPresent) { - val opterrorStateLabel = errorStateLabel.get() - put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) - } + val opterrorStateLabel = errorStateLabel.get() + put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) + } if (errorStateDetails.isPresent) { - val opterrorStateDetails = errorStateDetails.get() - put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) - } + val opterrorStateDetails = errorStateDetails.get() + put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) + } endStructure() } } @@ -59,23 +57,29 @@ class RvcOperationalStateClusterErrorStateStruct ( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterErrorStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return RvcOperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt index 930daff7a6d833..cc01c472f7f71b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcOperationalStateClusterOperationalStateStruct ( - val operationalStateID: UInt, - val operationalStateLabel: Optional) { - override fun toString(): String = buildString { +class RvcOperationalStateClusterOperationalStateStruct( + val operationalStateID: UInt, + val operationalStateLabel: Optional +) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationalStateStruct {\n") append("\toperationalStateID : $operationalStateID\n") append("\toperationalStateLabel : $operationalStateLabel\n") @@ -41,9 +39,9 @@ class RvcOperationalStateClusterOperationalStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D), operationalStateID) if (operationalStateLabel.isPresent) { - val optoperationalStateLabel = operationalStateLabel.get() - put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) - } + val optoperationalStateLabel = operationalStateLabel.get() + put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) + } endStructure() } } @@ -52,18 +50,25 @@ class RvcOperationalStateClusterOperationalStateStruct ( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationalStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return RvcOperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt index 519546666e3b33..c20f7b3f626474 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcRunModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class RvcRunModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("RvcRunModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class RvcRunModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcRunModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcRunModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcRunModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt index c6183c3e89c585..4c32d28ee6ad67 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcRunModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("RvcRunModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class RvcRunModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class RvcRunModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcRunModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcRunModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcRunModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt index 58f02b50feda16..3cf9c98d53e6d1 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ScenesManagementClusterAttributeValuePair ( - val attributeID: ULong, - val attributeValue: ULong) { - override fun toString(): String = buildString { +class ScenesManagementClusterAttributeValuePair(val attributeID: ULong, val attributeValue: ULong) { + override fun toString(): String = buildString { append("ScenesManagementClusterAttributeValuePair {\n") append("\tattributeID : $attributeID\n") append("\tattributeValue : $attributeValue\n") @@ -49,11 +43,11 @@ class ScenesManagementClusterAttributeValuePair ( private const val TAG_ATTRIBUTE_I_D = 0 private const val TAG_ATTRIBUTE_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ScenesManagementClusterAttributeValuePair { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterAttributeValuePair { tlvReader.enterStructure(tlvTag) val attributeID = tlvReader.getULong(ContextSpecificTag(TAG_ATTRIBUTE_I_D)) val attributeValue = tlvReader.getULong(ContextSpecificTag(TAG_ATTRIBUTE_VALUE)) - + tlvReader.exitContainer() return ScenesManagementClusterAttributeValuePair(attributeID, attributeValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt index 6d4411c76baead..3ef60f519e09c2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ScenesManagementClusterExtensionFieldSet ( - val clusterID: ULong, - val attributeValueList: List) { - override fun toString(): String = buildString { +class ScenesManagementClusterExtensionFieldSet( + val clusterID: ULong, + val attributeValueList: List +) { + override fun toString(): String = buildString { append("ScenesManagementClusterExtensionFieldSet {\n") append("\tclusterID : $clusterID\n") append("\tattributeValueList : $attributeValueList\n") @@ -53,17 +51,18 @@ class ScenesManagementClusterExtensionFieldSet ( private const val TAG_CLUSTER_I_D = 0 private const val TAG_ATTRIBUTE_VALUE_LIST = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ScenesManagementClusterExtensionFieldSet { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterExtensionFieldSet { tlvReader.enterStructure(tlvTag) val clusterID = tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER_I_D)) - val attributeValueList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val attributeValueList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ScenesManagementClusterExtensionFieldSet(clusterID, attributeValueList) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt index 3ac060b092b76a..74979432fbc571 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt @@ -17,23 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ScenesManagementClusterSceneInfoStruct ( - val sceneCount: UInt, - val currentScene: UInt, - val currentGroup: UInt, - val sceneValid: Boolean, - val remainingCapacity: UInt, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class ScenesManagementClusterSceneInfoStruct( + val sceneCount: UInt, + val currentScene: UInt, + val currentGroup: UInt, + val sceneValid: Boolean, + val remainingCapacity: UInt, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("ScenesManagementClusterSceneInfoStruct {\n") append("\tsceneCount : $sceneCount\n") append("\tcurrentScene : $currentScene\n") @@ -65,7 +62,7 @@ class ScenesManagementClusterSceneInfoStruct ( private const val TAG_REMAINING_CAPACITY = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ScenesManagementClusterSceneInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterSceneInfoStruct { tlvReader.enterStructure(tlvTag) val sceneCount = tlvReader.getUInt(ContextSpecificTag(TAG_SCENE_COUNT)) val currentScene = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_SCENE)) @@ -73,10 +70,17 @@ class ScenesManagementClusterSceneInfoStruct ( val sceneValid = tlvReader.getBoolean(ContextSpecificTag(TAG_SCENE_VALID)) val remainingCapacity = tlvReader.getUInt(ContextSpecificTag(TAG_REMAINING_CAPACITY)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return ScenesManagementClusterSceneInfoStruct(sceneCount, currentScene, currentGroup, sceneValid, remainingCapacity, fabricIndex) + return ScenesManagementClusterSceneInfoStruct( + sceneCount, + currentScene, + currentGroup, + sceneValid, + remainingCapacity, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterHomeLocationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterHomeLocationStruct.kt index 71985c1b77fe51..7262fc9102917c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterHomeLocationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterHomeLocationStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ServiceAreaClusterHomeLocationStruct ( - val locationName: String, - val floorNumber: Int?, - val areaType: UInt?) { - override fun toString(): String = buildString { +class ServiceAreaClusterHomeLocationStruct( + val locationName: String, + val floorNumber: Int?, + val areaType: UInt? +) { + override fun toString(): String = buildString { append("ServiceAreaClusterHomeLocationStruct {\n") append("\tlocationName : $locationName\n") append("\tfloorNumber : $floorNumber\n") @@ -43,15 +40,15 @@ class ServiceAreaClusterHomeLocationStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_LOCATION_NAME), locationName) if (floorNumber != null) { - put(ContextSpecificTag(TAG_FLOOR_NUMBER), floorNumber) - } else { - putNull(ContextSpecificTag(TAG_FLOOR_NUMBER)) - } + put(ContextSpecificTag(TAG_FLOOR_NUMBER), floorNumber) + } else { + putNull(ContextSpecificTag(TAG_FLOOR_NUMBER)) + } if (areaType != null) { - put(ContextSpecificTag(TAG_AREA_TYPE), areaType) - } else { - putNull(ContextSpecificTag(TAG_AREA_TYPE)) - } + put(ContextSpecificTag(TAG_AREA_TYPE), areaType) + } else { + putNull(ContextSpecificTag(TAG_AREA_TYPE)) + } endStructure() } } @@ -61,22 +58,24 @@ class ServiceAreaClusterHomeLocationStruct ( private const val TAG_FLOOR_NUMBER = 1 private const val TAG_AREA_TYPE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ServiceAreaClusterHomeLocationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ServiceAreaClusterHomeLocationStruct { tlvReader.enterStructure(tlvTag) val locationName = tlvReader.getString(ContextSpecificTag(TAG_LOCATION_NAME)) - val floorNumber = if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_FLOOR_NUMBER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FLOOR_NUMBER)) - null - } - val areaType = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_AREA_TYPE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AREA_TYPE)) - null - } - + val floorNumber = + if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_FLOOR_NUMBER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FLOOR_NUMBER)) + null + } + val areaType = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_AREA_TYPE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AREA_TYPE)) + null + } + tlvReader.exitContainer() return ServiceAreaClusterHomeLocationStruct(locationName, floorNumber, areaType) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterLocationInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterLocationInfoStruct.kt index 57cfd41996b33f..4ddb164dd98834 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterLocationInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterLocationInfoStruct.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ServiceAreaClusterLocationInfoStruct ( - val locationInfo: ServiceAreaClusterHomeLocationStruct?, - val landmarkTag: UInt?, - val positionTag: UInt?, - val surfaceTag: UInt?) { - override fun toString(): String = buildString { +class ServiceAreaClusterLocationInfoStruct( + val locationInfo: ServiceAreaClusterHomeLocationStruct?, + val landmarkTag: UInt?, + val positionTag: UInt?, + val surfaceTag: UInt? +) { + override fun toString(): String = buildString { append("ServiceAreaClusterLocationInfoStruct {\n") append("\tlocationInfo : $locationInfo\n") append("\tlandmarkTag : $landmarkTag\n") @@ -44,25 +41,25 @@ class ServiceAreaClusterLocationInfoStruct ( tlvWriter.apply { startStructure(tlvTag) if (locationInfo != null) { - locationInfo.toTlv(ContextSpecificTag(TAG_LOCATION_INFO), this) - } else { - putNull(ContextSpecificTag(TAG_LOCATION_INFO)) - } + locationInfo.toTlv(ContextSpecificTag(TAG_LOCATION_INFO), this) + } else { + putNull(ContextSpecificTag(TAG_LOCATION_INFO)) + } if (landmarkTag != null) { - put(ContextSpecificTag(TAG_LANDMARK_TAG), landmarkTag) - } else { - putNull(ContextSpecificTag(TAG_LANDMARK_TAG)) - } + put(ContextSpecificTag(TAG_LANDMARK_TAG), landmarkTag) + } else { + putNull(ContextSpecificTag(TAG_LANDMARK_TAG)) + } if (positionTag != null) { - put(ContextSpecificTag(TAG_POSITION_TAG), positionTag) - } else { - putNull(ContextSpecificTag(TAG_POSITION_TAG)) - } + put(ContextSpecificTag(TAG_POSITION_TAG), positionTag) + } else { + putNull(ContextSpecificTag(TAG_POSITION_TAG)) + } if (surfaceTag != null) { - put(ContextSpecificTag(TAG_SURFACE_TAG), surfaceTag) - } else { - putNull(ContextSpecificTag(TAG_SURFACE_TAG)) - } + put(ContextSpecificTag(TAG_SURFACE_TAG), surfaceTag) + } else { + putNull(ContextSpecificTag(TAG_SURFACE_TAG)) + } endStructure() } } @@ -73,36 +70,48 @@ class ServiceAreaClusterLocationInfoStruct ( private const val TAG_POSITION_TAG = 2 private const val TAG_SURFACE_TAG = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ServiceAreaClusterLocationInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ServiceAreaClusterLocationInfoStruct { tlvReader.enterStructure(tlvTag) - val locationInfo = if (!tlvReader.isNull()) { - ServiceAreaClusterHomeLocationStruct.fromTlv(ContextSpecificTag(TAG_LOCATION_INFO), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LOCATION_INFO)) - null - } - val landmarkTag = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_LANDMARK_TAG)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LANDMARK_TAG)) - null - } - val positionTag = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_POSITION_TAG)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POSITION_TAG)) - null - } - val surfaceTag = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_SURFACE_TAG)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SURFACE_TAG)) - null - } - + val locationInfo = + if (!tlvReader.isNull()) { + ServiceAreaClusterHomeLocationStruct.fromTlv( + ContextSpecificTag(TAG_LOCATION_INFO), + tlvReader + ) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LOCATION_INFO)) + null + } + val landmarkTag = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_LANDMARK_TAG)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LANDMARK_TAG)) + null + } + val positionTag = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_POSITION_TAG)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POSITION_TAG)) + null + } + val surfaceTag = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_SURFACE_TAG)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SURFACE_TAG)) + null + } + tlvReader.exitContainer() - return ServiceAreaClusterLocationInfoStruct(locationInfo, landmarkTag, positionTag, surfaceTag) + return ServiceAreaClusterLocationInfoStruct( + locationInfo, + landmarkTag, + positionTag, + surfaceTag + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterLocationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterLocationStruct.kt index 074a9179f5e742..1e34a8c330b656 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterLocationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterLocationStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ServiceAreaClusterLocationStruct ( - val locationID: ULong, - val mapID: UInt?, - val locationInfo: ServiceAreaClusterLocationInfoStruct) { - override fun toString(): String = buildString { +class ServiceAreaClusterLocationStruct( + val locationID: ULong, + val mapID: UInt?, + val locationInfo: ServiceAreaClusterLocationInfoStruct +) { + override fun toString(): String = buildString { append("ServiceAreaClusterLocationStruct {\n") append("\tlocationID : $locationID\n") append("\tmapID : $mapID\n") @@ -43,10 +40,10 @@ class ServiceAreaClusterLocationStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_LOCATION_I_D), locationID) if (mapID != null) { - put(ContextSpecificTag(TAG_MAP_I_D), mapID) - } else { - putNull(ContextSpecificTag(TAG_MAP_I_D)) - } + put(ContextSpecificTag(TAG_MAP_I_D), mapID) + } else { + putNull(ContextSpecificTag(TAG_MAP_I_D)) + } locationInfo.toTlv(ContextSpecificTag(TAG_LOCATION_INFO), this) endStructure() } @@ -57,17 +54,22 @@ class ServiceAreaClusterLocationStruct ( private const val TAG_MAP_I_D = 1 private const val TAG_LOCATION_INFO = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ServiceAreaClusterLocationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ServiceAreaClusterLocationStruct { tlvReader.enterStructure(tlvTag) val locationID = tlvReader.getULong(ContextSpecificTag(TAG_LOCATION_I_D)) - val mapID = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_MAP_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MAP_I_D)) - null - } - val locationInfo = ServiceAreaClusterLocationInfoStruct.fromTlv(ContextSpecificTag(TAG_LOCATION_INFO), tlvReader) - + val mapID = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_MAP_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MAP_I_D)) + null + } + val locationInfo = + ServiceAreaClusterLocationInfoStruct.fromTlv( + ContextSpecificTag(TAG_LOCATION_INFO), + tlvReader + ) + tlvReader.exitContainer() return ServiceAreaClusterLocationStruct(locationID, mapID, locationInfo) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterMapStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterMapStruct.kt index 0f35fe46c7a21b..377ab13f0e9130 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterMapStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterMapStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ServiceAreaClusterMapStruct ( - val mapID: UInt, - val name: String) { - override fun toString(): String = buildString { +class ServiceAreaClusterMapStruct(val mapID: UInt, val name: String) { + override fun toString(): String = buildString { append("ServiceAreaClusterMapStruct {\n") append("\tmapID : $mapID\n") append("\tname : $name\n") @@ -49,11 +43,11 @@ class ServiceAreaClusterMapStruct ( private const val TAG_MAP_I_D = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ServiceAreaClusterMapStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ServiceAreaClusterMapStruct { tlvReader.enterStructure(tlvTag) val mapID = tlvReader.getUInt(ContextSpecificTag(TAG_MAP_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return ServiceAreaClusterMapStruct(mapID, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterProgressStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterProgressStruct.kt index 73f6e69be8a9f3..d65a0faa19c1a2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterProgressStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ServiceAreaClusterProgressStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ServiceAreaClusterProgressStruct ( - val locationID: ULong, - val status: UInt, - val totalOperationalTime: Optional?, - val estimatedTime: Optional?) { - override fun toString(): String = buildString { +class ServiceAreaClusterProgressStruct( + val locationID: ULong, + val status: UInt, + val totalOperationalTime: Optional?, + val estimatedTime: Optional? +) { + override fun toString(): String = buildString { append("ServiceAreaClusterProgressStruct {\n") append("\tlocationID : $locationID\n") append("\tstatus : $status\n") @@ -46,21 +44,21 @@ class ServiceAreaClusterProgressStruct ( put(ContextSpecificTag(TAG_LOCATION_I_D), locationID) put(ContextSpecificTag(TAG_STATUS), status) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (estimatedTime != null) { - if (estimatedTime.isPresent) { - val optestimatedTime = estimatedTime.get() - put(ContextSpecificTag(TAG_ESTIMATED_TIME), optestimatedTime) - } - } else { - putNull(ContextSpecificTag(TAG_ESTIMATED_TIME)) - } + if (estimatedTime.isPresent) { + val optestimatedTime = estimatedTime.get() + put(ContextSpecificTag(TAG_ESTIMATED_TIME), optestimatedTime) + } + } else { + putNull(ContextSpecificTag(TAG_ESTIMATED_TIME)) + } endStructure() } } @@ -71,34 +69,41 @@ class ServiceAreaClusterProgressStruct ( private const val TAG_TOTAL_OPERATIONAL_TIME = 2 private const val TAG_ESTIMATED_TIME = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ServiceAreaClusterProgressStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ServiceAreaClusterProgressStruct { tlvReader.enterStructure(tlvTag) val locationID = tlvReader.getULong(ContextSpecificTag(TAG_LOCATION_I_D)) val status = tlvReader.getUInt(ContextSpecificTag(TAG_STATUS)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val estimatedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ESTIMATED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_ESTIMATED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ESTIMATED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val estimatedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ESTIMATED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_ESTIMATED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ESTIMATED_TIME)) + null + } + tlvReader.exitContainer() - return ServiceAreaClusterProgressStruct(locationID, status, totalOperationalTime, estimatedTime) + return ServiceAreaClusterProgressStruct( + locationID, + status, + totalOperationalTime, + estimatedTime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt index 3ef4fc6b3bbfa6..f606a46f9fd057 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SoftwareDiagnosticsClusterThreadMetricsStruct ( - val id: ULong, - val name: Optional, - val stackFreeCurrent: Optional, - val stackFreeMinimum: Optional, - val stackSize: Optional) { - override fun toString(): String = buildString { +class SoftwareDiagnosticsClusterThreadMetricsStruct( + val id: ULong, + val name: Optional, + val stackFreeCurrent: Optional, + val stackFreeMinimum: Optional, + val stackSize: Optional +) { + override fun toString(): String = buildString { append("SoftwareDiagnosticsClusterThreadMetricsStruct {\n") append("\tid : $id\n") append("\tname : $name\n") @@ -47,21 +45,21 @@ class SoftwareDiagnosticsClusterThreadMetricsStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ID), id) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (stackFreeCurrent.isPresent) { - val optstackFreeCurrent = stackFreeCurrent.get() - put(ContextSpecificTag(TAG_STACK_FREE_CURRENT), optstackFreeCurrent) - } + val optstackFreeCurrent = stackFreeCurrent.get() + put(ContextSpecificTag(TAG_STACK_FREE_CURRENT), optstackFreeCurrent) + } if (stackFreeMinimum.isPresent) { - val optstackFreeMinimum = stackFreeMinimum.get() - put(ContextSpecificTag(TAG_STACK_FREE_MINIMUM), optstackFreeMinimum) - } + val optstackFreeMinimum = stackFreeMinimum.get() + put(ContextSpecificTag(TAG_STACK_FREE_MINIMUM), optstackFreeMinimum) + } if (stackSize.isPresent) { - val optstackSize = stackSize.get() - put(ContextSpecificTag(TAG_STACK_SIZE), optstackSize) - } + val optstackSize = stackSize.get() + put(ContextSpecificTag(TAG_STACK_SIZE), optstackSize) + } endStructure() } } @@ -73,33 +71,43 @@ class SoftwareDiagnosticsClusterThreadMetricsStruct ( private const val TAG_STACK_FREE_MINIMUM = 3 private const val TAG_STACK_SIZE = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SoftwareDiagnosticsClusterThreadMetricsStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterThreadMetricsStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val stackFreeCurrent = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) - } else { - Optional.empty() - } - val stackFreeMinimum = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) - } else { - Optional.empty() - } - val stackSize = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_SIZE))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val stackFreeCurrent = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) + } else { + Optional.empty() + } + val stackFreeMinimum = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) + } else { + Optional.empty() + } + val stackSize = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_SIZE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return SoftwareDiagnosticsClusterThreadMetricsStruct(id, name, stackFreeCurrent, stackFreeMinimum, stackSize) + return SoftwareDiagnosticsClusterThreadMetricsStruct( + id, + name, + stackFreeCurrent, + stackFreeMinimum, + stackSize + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt index 49ebd8e74713c8..8d667ba0f94cfa 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TargetNavigatorClusterTargetInfoStruct ( - val identifier: UInt, - val name: String) { - override fun toString(): String = buildString { +class TargetNavigatorClusterTargetInfoStruct(val identifier: UInt, val name: String) { + override fun toString(): String = buildString { append("TargetNavigatorClusterTargetInfoStruct {\n") append("\tidentifier : $identifier\n") append("\tname : $name\n") @@ -49,11 +43,11 @@ class TargetNavigatorClusterTargetInfoStruct ( private const val TAG_IDENTIFIER = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TargetNavigatorClusterTargetInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetInfoStruct { tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getUInt(ContextSpecificTag(TAG_IDENTIFIER)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetInfoStruct(identifier, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt index 5b426e8234fc4d..cb91c04d920b9c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt @@ -17,23 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterPresetStruct ( - val presetHandle: ByteArray?, - val presetScenario: UInt, - val name: Optional?, - val coolingSetpoint: Optional, - val heatingSetpoint: Optional, - val builtIn: Boolean?) { - override fun toString(): String = buildString { +class ThermostatClusterPresetStruct( + val presetHandle: ByteArray?, + val presetScenario: UInt, + val name: Optional?, + val coolingSetpoint: Optional, + val heatingSetpoint: Optional, + val builtIn: Boolean? +) { + override fun toString(): String = buildString { append("ThermostatClusterPresetStruct {\n") append("\tpresetHandle : $presetHandle\n") append("\tpresetScenario : $presetScenario\n") @@ -48,32 +46,32 @@ class ThermostatClusterPresetStruct ( tlvWriter.apply { startStructure(tlvTag) if (presetHandle != null) { - put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) - } else { - putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - } + put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) + } else { + putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + } put(ContextSpecificTag(TAG_PRESET_SCENARIO), presetScenario) if (name != null) { - if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } - } else { - putNull(ContextSpecificTag(TAG_NAME)) - } + if (name.isPresent) { + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } + } else { + putNull(ContextSpecificTag(TAG_NAME)) + } if (coolingSetpoint.isPresent) { - val optcoolingSetpoint = coolingSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) - } + val optcoolingSetpoint = coolingSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) + } if (heatingSetpoint.isPresent) { - val optheatingSetpoint = heatingSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) - } + val optheatingSetpoint = heatingSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) + } if (builtIn != null) { - put(ContextSpecificTag(TAG_BUILT_IN), builtIn) - } else { - putNull(ContextSpecificTag(TAG_BUILT_IN)) - } + put(ContextSpecificTag(TAG_BUILT_IN), builtIn) + } else { + putNull(ContextSpecificTag(TAG_BUILT_IN)) + } endStructure() } } @@ -86,45 +84,57 @@ class ThermostatClusterPresetStruct ( private const val TAG_HEATING_SETPOINT = 4 private const val TAG_BUILT_IN = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterPresetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } + val presetHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } val presetScenario = tlvReader.getUInt(ContextSpecificTag(TAG_PRESET_SCENARIO)) - val name = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NAME)) - null - } - val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - val builtIn = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NAME)) + null + } + val coolingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + val builtIn = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterPresetStruct(presetHandle, presetScenario, name, coolingSetpoint, heatingSetpoint, builtIn) + return ThermostatClusterPresetStruct( + presetHandle, + presetScenario, + name, + coolingSetpoint, + heatingSetpoint, + builtIn + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt index 26a9bab02f91e6..386af8f682e665 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterPresetTypeStruct ( - val presetScenario: UInt, - val numberOfPresets: UInt, - val presetTypeFeatures: UInt) { - override fun toString(): String = buildString { +class ThermostatClusterPresetTypeStruct( + val presetScenario: UInt, + val numberOfPresets: UInt, + val presetTypeFeatures: UInt +) { + override fun toString(): String = buildString { append("ThermostatClusterPresetTypeStruct {\n") append("\tpresetScenario : $presetScenario\n") append("\tnumberOfPresets : $numberOfPresets\n") @@ -53,12 +50,12 @@ class ThermostatClusterPresetTypeStruct ( private const val TAG_NUMBER_OF_PRESETS = 1 private const val TAG_PRESET_TYPE_FEATURES = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterPresetTypeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterPresetTypeStruct { tlvReader.enterStructure(tlvTag) val presetScenario = tlvReader.getUInt(ContextSpecificTag(TAG_PRESET_SCENARIO)) val numberOfPresets = tlvReader.getUInt(ContextSpecificTag(TAG_NUMBER_OF_PRESETS)) val presetTypeFeatures = tlvReader.getUInt(ContextSpecificTag(TAG_PRESET_TYPE_FEATURES)) - + tlvReader.exitContainer() return ThermostatClusterPresetTypeStruct(presetScenario, numberOfPresets, presetTypeFeatures) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt index 92e30614970dd2..4ecaecf98901dc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterQueuedPresetStruct ( - val presetHandle: ByteArray?, - val transitionTimestamp: ULong?) { - override fun toString(): String = buildString { +class ThermostatClusterQueuedPresetStruct( + val presetHandle: ByteArray?, + val transitionTimestamp: ULong? +) { + override fun toString(): String = buildString { append("ThermostatClusterQueuedPresetStruct {\n") append("\tpresetHandle : $presetHandle\n") append("\ttransitionTimestamp : $transitionTimestamp\n") @@ -40,15 +37,15 @@ class ThermostatClusterQueuedPresetStruct ( tlvWriter.apply { startStructure(tlvTag) if (presetHandle != null) { - put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) - } else { - putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - } + put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) + } else { + putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + } if (transitionTimestamp != null) { - put(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP), transitionTimestamp) - } else { - putNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - } + put(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP), transitionTimestamp) + } else { + putNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + } endStructure() } } @@ -57,21 +54,23 @@ class ThermostatClusterQueuedPresetStruct ( private const val TAG_PRESET_HANDLE = 0 private const val TAG_TRANSITION_TIMESTAMP = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterQueuedPresetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterQueuedPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } - val transitionTimestamp = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - null - } - + val presetHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } + val transitionTimestamp = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + null + } + tlvReader.exitContainer() return ThermostatClusterQueuedPresetStruct(presetHandle, transitionTimestamp) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt index f07278bc4b607a..ac1ffbde1caca9 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt @@ -17,23 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterScheduleStruct ( - val scheduleHandle: ByteArray?, - val systemMode: UInt, - val name: Optional, - val presetHandle: Optional, - val transitions: List, - val builtIn: Optional?) { - override fun toString(): String = buildString { +class ThermostatClusterScheduleStruct( + val scheduleHandle: ByteArray?, + val systemMode: UInt, + val name: Optional, + val presetHandle: Optional, + val transitions: List, + val builtIn: Optional? +) { + override fun toString(): String = buildString { append("ThermostatClusterScheduleStruct {\n") append("\tscheduleHandle : $scheduleHandle\n") append("\tsystemMode : $systemMode\n") @@ -48,32 +47,32 @@ class ThermostatClusterScheduleStruct ( tlvWriter.apply { startStructure(tlvTag) if (scheduleHandle != null) { - put(ContextSpecificTag(TAG_SCHEDULE_HANDLE), scheduleHandle) - } else { - putNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - } + put(ContextSpecificTag(TAG_SCHEDULE_HANDLE), scheduleHandle) + } else { + putNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + } put(ContextSpecificTag(TAG_SYSTEM_MODE), systemMode) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (presetHandle.isPresent) { - val optpresetHandle = presetHandle.get() - put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) - } + val optpresetHandle = presetHandle.get() + put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) + } startArray(ContextSpecificTag(TAG_TRANSITIONS)) for (item in transitions.iterator()) { item.toTlv(AnonymousTag, this) } endArray() if (builtIn != null) { - if (builtIn.isPresent) { - val optbuiltIn = builtIn.get() - put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) - } - } else { - putNull(ContextSpecificTag(TAG_BUILT_IN)) - } + if (builtIn.isPresent) { + val optbuiltIn = builtIn.get() + put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) + } + } else { + putNull(ContextSpecificTag(TAG_BUILT_IN)) + } endStructure() } } @@ -86,46 +85,58 @@ class ThermostatClusterScheduleStruct ( private const val TAG_TRANSITIONS = 4 private const val TAG_BUILT_IN = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterScheduleStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleStruct { tlvReader.enterStructure(tlvTag) - val scheduleHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - null - } + val scheduleHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + null + } val systemMode = tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val transitions = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val builtIn = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val presetHandle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val transitions = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val builtIn = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterScheduleStruct(scheduleHandle, systemMode, name, presetHandle, transitions, builtIn) + return ThermostatClusterScheduleStruct( + scheduleHandle, + systemMode, + name, + presetHandle, + transitions, + builtIn + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt index e429994e90d20a..aabb3b6418da7b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt @@ -17,23 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterScheduleTransitionStruct ( - val dayOfWeek: UInt, - val transitionTime: UInt, - val presetHandle: Optional, - val systemMode: Optional, - val coolingSetpoint: Optional, - val heatingSetpoint: Optional) { - override fun toString(): String = buildString { +class ThermostatClusterScheduleTransitionStruct( + val dayOfWeek: UInt, + val transitionTime: UInt, + val presetHandle: Optional, + val systemMode: Optional, + val coolingSetpoint: Optional, + val heatingSetpoint: Optional +) { + override fun toString(): String = buildString { append("ThermostatClusterScheduleTransitionStruct {\n") append("\tdayOfWeek : $dayOfWeek\n") append("\ttransitionTime : $transitionTime\n") @@ -50,21 +48,21 @@ class ThermostatClusterScheduleTransitionStruct ( put(ContextSpecificTag(TAG_DAY_OF_WEEK), dayOfWeek) put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime) if (presetHandle.isPresent) { - val optpresetHandle = presetHandle.get() - put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) - } + val optpresetHandle = presetHandle.get() + put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) + } if (systemMode.isPresent) { - val optsystemMode = systemMode.get() - put(ContextSpecificTag(TAG_SYSTEM_MODE), optsystemMode) - } + val optsystemMode = systemMode.get() + put(ContextSpecificTag(TAG_SYSTEM_MODE), optsystemMode) + } if (coolingSetpoint.isPresent) { - val optcoolingSetpoint = coolingSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) - } + val optcoolingSetpoint = coolingSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) + } if (heatingSetpoint.isPresent) { - val optheatingSetpoint = heatingSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) - } + val optheatingSetpoint = heatingSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) + } endStructure() } } @@ -77,34 +75,45 @@ class ThermostatClusterScheduleTransitionStruct ( private const val TAG_COOLING_SETPOINT = 4 private const val TAG_HEATING_SETPOINT = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterScheduleTransitionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleTransitionStruct { tlvReader.enterStructure(tlvTag) val dayOfWeek = tlvReader.getUInt(ContextSpecificTag(TAG_DAY_OF_WEEK)) val transitionTime = tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIME)) - val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val systemMode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE))) - } else { - Optional.empty() - } - val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - + val presetHandle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val systemMode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE))) + } else { + Optional.empty() + } + val coolingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ThermostatClusterScheduleTransitionStruct(dayOfWeek, transitionTime, presetHandle, systemMode, coolingSetpoint, heatingSetpoint) + return ThermostatClusterScheduleTransitionStruct( + dayOfWeek, + transitionTime, + presetHandle, + systemMode, + coolingSetpoint, + heatingSetpoint + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt index 02b2c88e6c9d01..eb62cbf32b28a4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterScheduleTypeStruct ( - val systemMode: UInt, - val numberOfSchedules: UInt, - val scheduleTypeFeatures: UInt) { - override fun toString(): String = buildString { +class ThermostatClusterScheduleTypeStruct( + val systemMode: UInt, + val numberOfSchedules: UInt, + val scheduleTypeFeatures: UInt +) { + override fun toString(): String = buildString { append("ThermostatClusterScheduleTypeStruct {\n") append("\tsystemMode : $systemMode\n") append("\tnumberOfSchedules : $numberOfSchedules\n") @@ -53,15 +50,19 @@ class ThermostatClusterScheduleTypeStruct ( private const val TAG_NUMBER_OF_SCHEDULES = 1 private const val TAG_SCHEDULE_TYPE_FEATURES = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterScheduleTypeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleTypeStruct { tlvReader.enterStructure(tlvTag) val systemMode = tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE)) val numberOfSchedules = tlvReader.getUInt(ContextSpecificTag(TAG_NUMBER_OF_SCHEDULES)) val scheduleTypeFeatures = tlvReader.getUInt(ContextSpecificTag(TAG_SCHEDULE_TYPE_FEATURES)) - + tlvReader.exitContainer() - return ThermostatClusterScheduleTypeStruct(systemMode, numberOfSchedules, scheduleTypeFeatures) + return ThermostatClusterScheduleTypeStruct( + systemMode, + numberOfSchedules, + scheduleTypeFeatures + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt index b033662cbf23b2..343952b9a54a79 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterWeeklyScheduleTransitionStruct ( - val transitionTime: UInt, - val heatSetpoint: Int?, - val coolSetpoint: Int?) { - override fun toString(): String = buildString { +class ThermostatClusterWeeklyScheduleTransitionStruct( + val transitionTime: UInt, + val heatSetpoint: Int?, + val coolSetpoint: Int? +) { + override fun toString(): String = buildString { append("ThermostatClusterWeeklyScheduleTransitionStruct {\n") append("\ttransitionTime : $transitionTime\n") append("\theatSetpoint : $heatSetpoint\n") @@ -43,15 +40,15 @@ class ThermostatClusterWeeklyScheduleTransitionStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime) if (heatSetpoint != null) { - put(ContextSpecificTag(TAG_HEAT_SETPOINT), heatSetpoint) - } else { - putNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } + put(ContextSpecificTag(TAG_HEAT_SETPOINT), heatSetpoint) + } else { + putNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) + } if (coolSetpoint != null) { - put(ContextSpecificTag(TAG_COOL_SETPOINT), coolSetpoint) - } else { - putNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - } + put(ContextSpecificTag(TAG_COOL_SETPOINT), coolSetpoint) + } else { + putNull(ContextSpecificTag(TAG_COOL_SETPOINT)) + } endStructure() } } @@ -61,25 +58,34 @@ class ThermostatClusterWeeklyScheduleTransitionStruct ( private const val TAG_HEAT_SETPOINT = 1 private const val TAG_COOL_SETPOINT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterWeeklyScheduleTransitionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThermostatClusterWeeklyScheduleTransitionStruct { tlvReader.enterStructure(tlvTag) val transitionTime = tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIME)) - val heatSetpoint = if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - null - } - val coolSetpoint = if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_COOL_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - null - } - + val heatSetpoint = + if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_HEAT_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) + null + } + val coolSetpoint = + if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_COOL_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) + null + } + tlvReader.exitContainer() - return ThermostatClusterWeeklyScheduleTransitionStruct(transitionTime, heatSetpoint, coolSetpoint) + return ThermostatClusterWeeklyScheduleTransitionStruct( + transitionTime, + heatSetpoint, + coolSetpoint + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt index 40156c06651284..84733d5bd9d5fc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt @@ -17,31 +17,28 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterNeighborTableStruct ( - val extAddress: ULong, - val age: ULong, - val rloc16: UInt, - val linkFrameCounter: ULong, - val mleFrameCounter: ULong, - val lqi: UInt, - val averageRssi: Int?, - val lastRssi: Int?, - val frameErrorRate: UInt, - val messageErrorRate: UInt, - val rxOnWhenIdle: Boolean, - val fullThreadDevice: Boolean, - val fullNetworkData: Boolean, - val isChild: Boolean) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterNeighborTableStruct( + val extAddress: ULong, + val age: ULong, + val rloc16: UInt, + val linkFrameCounter: ULong, + val mleFrameCounter: ULong, + val lqi: UInt, + val averageRssi: Int?, + val lastRssi: Int?, + val frameErrorRate: UInt, + val messageErrorRate: UInt, + val rxOnWhenIdle: Boolean, + val fullThreadDevice: Boolean, + val fullNetworkData: Boolean, + val isChild: Boolean +) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterNeighborTableStruct {\n") append("\textAddress : $extAddress\n") append("\tage : $age\n") @@ -70,15 +67,15 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct ( put(ContextSpecificTag(TAG_MLE_FRAME_COUNTER), mleFrameCounter) put(ContextSpecificTag(TAG_LQI), lqi) if (averageRssi != null) { - put(ContextSpecificTag(TAG_AVERAGE_RSSI), averageRssi) - } else { - putNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) - } + put(ContextSpecificTag(TAG_AVERAGE_RSSI), averageRssi) + } else { + putNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) + } if (lastRssi != null) { - put(ContextSpecificTag(TAG_LAST_RSSI), lastRssi) - } else { - putNull(ContextSpecificTag(TAG_LAST_RSSI)) - } + put(ContextSpecificTag(TAG_LAST_RSSI), lastRssi) + } else { + putNull(ContextSpecificTag(TAG_LAST_RSSI)) + } put(ContextSpecificTag(TAG_FRAME_ERROR_RATE), frameErrorRate) put(ContextSpecificTag(TAG_MESSAGE_ERROR_RATE), messageErrorRate) put(ContextSpecificTag(TAG_RX_ON_WHEN_IDLE), rxOnWhenIdle) @@ -105,7 +102,10 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct ( private const val TAG_FULL_NETWORK_DATA = 12 private const val TAG_IS_CHILD = 13 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterNeighborTableStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterNeighborTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val age = tlvReader.getULong(ContextSpecificTag(TAG_AGE)) @@ -113,28 +113,45 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct ( val linkFrameCounter = tlvReader.getULong(ContextSpecificTag(TAG_LINK_FRAME_COUNTER)) val mleFrameCounter = tlvReader.getULong(ContextSpecificTag(TAG_MLE_FRAME_COUNTER)) val lqi = tlvReader.getUInt(ContextSpecificTag(TAG_LQI)) - val averageRssi = if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_AVERAGE_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) - null - } - val lastRssi = if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_LAST_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) - null - } + val averageRssi = + if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_AVERAGE_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) + null + } + val lastRssi = + if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_LAST_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) + null + } val frameErrorRate = tlvReader.getUInt(ContextSpecificTag(TAG_FRAME_ERROR_RATE)) val messageErrorRate = tlvReader.getUInt(ContextSpecificTag(TAG_MESSAGE_ERROR_RATE)) val rxOnWhenIdle = tlvReader.getBoolean(ContextSpecificTag(TAG_RX_ON_WHEN_IDLE)) val fullThreadDevice = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_THREAD_DEVICE)) val fullNetworkData = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_NETWORK_DATA)) val isChild = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_CHILD)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterNeighborTableStruct(extAddress, age, rloc16, linkFrameCounter, mleFrameCounter, lqi, averageRssi, lastRssi, frameErrorRate, messageErrorRate, rxOnWhenIdle, fullThreadDevice, fullNetworkData, isChild) + return ThreadNetworkDiagnosticsClusterNeighborTableStruct( + extAddress, + age, + rloc16, + linkFrameCounter, + mleFrameCounter, + lqi, + averageRssi, + lastRssi, + frameErrorRate, + messageErrorRate, + rxOnWhenIdle, + fullThreadDevice, + fullNetworkData, + isChild + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt index b236dab6cb1906..39938fd1ee6403 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt @@ -17,29 +17,26 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents ( - val activeTimestampPresent: Boolean, - val pendingTimestampPresent: Boolean, - val masterKeyPresent: Boolean, - val networkNamePresent: Boolean, - val extendedPanIdPresent: Boolean, - val meshLocalPrefixPresent: Boolean, - val delayPresent: Boolean, - val panIdPresent: Boolean, - val channelPresent: Boolean, - val pskcPresent: Boolean, - val securityPolicyPresent: Boolean, - val channelMaskPresent: Boolean) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( + val activeTimestampPresent: Boolean, + val pendingTimestampPresent: Boolean, + val masterKeyPresent: Boolean, + val networkNamePresent: Boolean, + val extendedPanIdPresent: Boolean, + val meshLocalPrefixPresent: Boolean, + val delayPresent: Boolean, + val panIdPresent: Boolean, + val channelPresent: Boolean, + val pskcPresent: Boolean, + val securityPolicyPresent: Boolean, + val channelMaskPresent: Boolean +) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterOperationalDatasetComponents {\n") append("\tactiveTimestampPresent : $activeTimestampPresent\n") append("\tpendingTimestampPresent : $pendingTimestampPresent\n") @@ -89,24 +86,45 @@ class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents ( private const val TAG_SECURITY_POLICY_PRESENT = 10 private const val TAG_CHANNEL_MASK_PRESENT = 11 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { tlvReader.enterStructure(tlvTag) - val activeTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) - val pendingTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) + val activeTimestampPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) + val pendingTimestampPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) val masterKeyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MASTER_KEY_PRESENT)) val networkNamePresent = tlvReader.getBoolean(ContextSpecificTag(TAG_NETWORK_NAME_PRESENT)) - val extendedPanIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) - val meshLocalPrefixPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) + val extendedPanIdPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) + val meshLocalPrefixPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) val delayPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_DELAY_PRESENT)) val panIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PAN_ID_PRESENT)) val channelPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_PRESENT)) val pskcPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PSKC_PRESENT)) - val securityPolicyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) + val securityPolicyPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) val channelMaskPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_MASK_PRESENT)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents(activeTimestampPresent, pendingTimestampPresent, masterKeyPresent, networkNamePresent, extendedPanIdPresent, meshLocalPrefixPresent, delayPresent, panIdPresent, channelPresent, pskcPresent, securityPolicyPresent, channelMaskPresent) + return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( + activeTimestampPresent, + pendingTimestampPresent, + masterKeyPresent, + networkNamePresent, + extendedPanIdPresent, + meshLocalPrefixPresent, + delayPresent, + panIdPresent, + channelPresent, + pskcPresent, + securityPolicyPresent, + channelMaskPresent + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt index 3d5edad134669d..d1bbbec7592462 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt @@ -17,27 +17,24 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterRouteTableStruct ( - val extAddress: ULong, - val rloc16: UInt, - val routerId: UInt, - val nextHop: UInt, - val pathCost: UInt, - val LQIIn: UInt, - val LQIOut: UInt, - val age: UInt, - val allocated: Boolean, - val linkEstablished: Boolean) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterRouteTableStruct( + val extAddress: ULong, + val rloc16: UInt, + val routerId: UInt, + val nextHop: UInt, + val pathCost: UInt, + val LQIIn: UInt, + val LQIOut: UInt, + val age: UInt, + val allocated: Boolean, + val linkEstablished: Boolean +) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterRouteTableStruct {\n") append("\textAddress : $extAddress\n") append("\trloc16 : $rloc16\n") @@ -81,7 +78,10 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct ( private const val TAG_ALLOCATED = 8 private const val TAG_LINK_ESTABLISHED = 9 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterRouteTableStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterRouteTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val rloc16 = tlvReader.getUInt(ContextSpecificTag(TAG_RLOC16)) @@ -93,10 +93,21 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct ( val age = tlvReader.getUInt(ContextSpecificTag(TAG_AGE)) val allocated = tlvReader.getBoolean(ContextSpecificTag(TAG_ALLOCATED)) val linkEstablished = tlvReader.getBoolean(ContextSpecificTag(TAG_LINK_ESTABLISHED)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterRouteTableStruct(extAddress, rloc16, routerId, nextHop, pathCost, LQIIn, LQIOut, age, allocated, linkEstablished) + return ThreadNetworkDiagnosticsClusterRouteTableStruct( + extAddress, + rloc16, + routerId, + nextHop, + pathCost, + LQIIn, + LQIOut, + age, + allocated, + linkEstablished + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt index 44eec2ff64ab26..c0d8b857424511 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterSecurityPolicy ( - val rotationTime: UInt, - val flags: UInt) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterSecurityPolicy(val rotationTime: UInt, val flags: UInt) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterSecurityPolicy {\n") append("\trotationTime : $rotationTime\n") append("\tflags : $flags\n") @@ -49,11 +43,11 @@ class ThreadNetworkDiagnosticsClusterSecurityPolicy ( private const val TAG_ROTATION_TIME = 0 private const val TAG_FLAGS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterSecurityPolicy { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterSecurityPolicy { tlvReader.enterStructure(tlvTag) val rotationTime = tlvReader.getUInt(ContextSpecificTag(TAG_ROTATION_TIME)) val flags = tlvReader.getUInt(ContextSpecificTag(TAG_FLAGS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterSecurityPolicy(rotationTime, flags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDirectoryClusterThreadNetworkStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDirectoryClusterThreadNetworkStruct.kt index a22ee95c0ad104..ffc00a108110d7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDirectoryClusterThreadNetworkStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDirectoryClusterThreadNetworkStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDirectoryClusterThreadNetworkStruct ( - val extendedPanID: ULong, - val networkName: String, - val channel: UInt) { - override fun toString(): String = buildString { +class ThreadNetworkDirectoryClusterThreadNetworkStruct( + val extendedPanID: ULong, + val networkName: String, + val channel: UInt +) { + override fun toString(): String = buildString { append("ThreadNetworkDirectoryClusterThreadNetworkStruct {\n") append("\textendedPanID : $extendedPanID\n") append("\tnetworkName : $networkName\n") @@ -53,12 +50,15 @@ class ThreadNetworkDirectoryClusterThreadNetworkStruct ( private const val TAG_NETWORK_NAME = 1 private const val TAG_CHANNEL = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDirectoryClusterThreadNetworkStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDirectoryClusterThreadNetworkStruct { tlvReader.enterStructure(tlvTag) val extendedPanID = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_I_D)) val networkName = tlvReader.getString(ContextSpecificTag(TAG_NETWORK_NAME)) val channel = tlvReader.getUInt(ContextSpecificTag(TAG_CHANNEL)) - + tlvReader.exitContainer() return ThreadNetworkDirectoryClusterThreadNetworkStruct(extendedPanID, networkName, channel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt index c960f8a3d1e069..6df9767939dcef 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterDSTOffsetStruct ( - val offset: Long, - val validStarting: ULong, - val validUntil: ULong?) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterDSTOffsetStruct( + val offset: Long, + val validStarting: ULong, + val validUntil: ULong? +) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterDSTOffsetStruct {\n") append("\toffset : $offset\n") append("\tvalidStarting : $validStarting\n") @@ -44,10 +41,10 @@ class TimeSynchronizationClusterDSTOffsetStruct ( put(ContextSpecificTag(TAG_OFFSET), offset) put(ContextSpecificTag(TAG_VALID_STARTING), validStarting) if (validUntil != null) { - put(ContextSpecificTag(TAG_VALID_UNTIL), validUntil) - } else { - putNull(ContextSpecificTag(TAG_VALID_UNTIL)) - } + put(ContextSpecificTag(TAG_VALID_UNTIL), validUntil) + } else { + putNull(ContextSpecificTag(TAG_VALID_UNTIL)) + } endStructure() } } @@ -57,17 +54,18 @@ class TimeSynchronizationClusterDSTOffsetStruct ( private const val TAG_VALID_STARTING = 1 private const val TAG_VALID_UNTIL = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterDSTOffsetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterDSTOffsetStruct { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getLong(ContextSpecificTag(TAG_OFFSET)) val validStarting = tlvReader.getULong(ContextSpecificTag(TAG_VALID_STARTING)) - val validUntil = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) - null - } - + val validUntil = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) + null + } + tlvReader.exitContainer() return TimeSynchronizationClusterDSTOffsetStruct(offset, validStarting, validUntil) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt index 956908c9cd381d..cca59a20972c7b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct ( - val nodeID: ULong, - val endpoint: UInt) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct( + val nodeID: ULong, + val endpoint: UInt +) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct {\n") append("\tnodeID : $nodeID\n") append("\tendpoint : $endpoint\n") @@ -49,11 +46,14 @@ class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct ( private const val TAG_NODE_I_D = 0 private const val TAG_ENDPOINT = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct(nodeID, endpoint) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt index d972f05dbd528a..0d870bb1aa4b11 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterTimeZoneStruct ( - val offset: Long, - val validAt: ULong, - val name: Optional) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterTimeZoneStruct( + val offset: Long, + val validAt: ULong, + val name: Optional +) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterTimeZoneStruct {\n") append("\toffset : $offset\n") append("\tvalidAt : $validAt\n") @@ -44,9 +42,9 @@ class TimeSynchronizationClusterTimeZoneStruct ( put(ContextSpecificTag(TAG_OFFSET), offset) put(ContextSpecificTag(TAG_VALID_AT), validAt) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } endStructure() } } @@ -56,16 +54,17 @@ class TimeSynchronizationClusterTimeZoneStruct ( private const val TAG_VALID_AT = 1 private const val TAG_NAME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTimeZoneStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTimeZoneStruct { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getLong(ContextSpecificTag(TAG_OFFSET)) val validAt = tlvReader.getULong(ContextSpecificTag(TAG_VALID_AT)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStruct(offset, validAt, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt index 16685608686cb7..db6786d49ee802 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterTrustedTimeSourceStruct ( - val fabricIndex: UInt, - val nodeID: ULong, - val endpoint: UInt) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterTrustedTimeSourceStruct( + val fabricIndex: UInt, + val nodeID: ULong, + val endpoint: UInt +) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterTrustedTimeSourceStruct {\n") append("\tfabricIndex : $fabricIndex\n") append("\tnodeID : $nodeID\n") @@ -53,12 +50,15 @@ class TimeSynchronizationClusterTrustedTimeSourceStruct ( private const val TAG_NODE_I_D = 1 private const val TAG_ENDPOINT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTrustedTimeSourceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): TimeSynchronizationClusterTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterTrustedTimeSourceStruct(fabricIndex, nodeID, endpoint) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt index 4ae6ee1b7692ff..46ebbe20eb1528 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt @@ -20,15 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterDoubleNestedStructList ( - val a: List) { - override fun toString(): String = buildString { +class UnitTestingClusterDoubleNestedStructList(val a: List) { + override fun toString(): String = buildString { append("UnitTestingClusterDoubleNestedStructList {\n") append("\ta : $a\n") append("}\n") @@ -49,16 +45,17 @@ class UnitTestingClusterDoubleNestedStructList ( companion object { private const val TAG_A = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterDoubleNestedStructList { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterDoubleNestedStructList { tlvReader.enterStructure(tlvTag) - val a = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_A)) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val a = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_A)) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterDoubleNestedStructList(a) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt index 0a3799929a49c6..cd2c6a5d251fe9 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterNestedStruct ( - val a: UInt, - val b: Boolean, - val c: UnitTestingClusterSimpleStruct) { - override fun toString(): String = buildString { +class UnitTestingClusterNestedStruct( + val a: UInt, + val b: Boolean, + val c: UnitTestingClusterSimpleStruct +) { + override fun toString(): String = buildString { append("UnitTestingClusterNestedStruct {\n") append("\ta : $a\n") append("\tb : $b\n") @@ -53,12 +50,12 @@ class UnitTestingClusterNestedStruct ( private const val TAG_B = 1 private const val TAG_C = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterNestedStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNestedStruct { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - + tlvReader.exitContainer() return UnitTestingClusterNestedStruct(a, b, c) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt index 425b1753d17039..9b32b5343204c5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt @@ -20,21 +20,19 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterNestedStructList ( - val a: UInt, - val b: Boolean, - val c: UnitTestingClusterSimpleStruct, - val d: List, - val e: List, - val f: List, - val g: List) { - override fun toString(): String = buildString { +class UnitTestingClusterNestedStructList( + val a: UInt, + val b: Boolean, + val c: UnitTestingClusterSimpleStruct, + val d: List, + val e: List, + val f: List, + val g: List +) { + override fun toString(): String = buildString { append("UnitTestingClusterNestedStructList {\n") append("\ta : $a\n") append("\tb : $b\n") @@ -85,40 +83,44 @@ class UnitTestingClusterNestedStructList ( private const val TAG_F = 5 private const val TAG_G = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterNestedStructList { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNestedStructList { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - val d = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_D)) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val e = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_E)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getULong(AnonymousTag)) - } - tlvReader.exitContainer() - } - val f = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_F)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val g = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_G)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val d = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_D)) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val e = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_E)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getULong(AnonymousTag)) + } + tlvReader.exitContainer() + } + val f = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_F)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val g = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_G)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterNestedStructList(a, b, c, d, e, f, g) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt index 4758e679ca22cb..e8f12057027054 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt @@ -17,29 +17,28 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterNullablesAndOptionalsStruct ( - val nullableInt: UInt?, - val optionalInt: Optional, - val nullableOptionalInt: Optional?, - val nullableString: String?, - val optionalString: Optional, - val nullableOptionalString: Optional?, - val nullableStruct: UnitTestingClusterSimpleStruct?, - val optionalStruct: Optional, - val nullableOptionalStruct: Optional?, - val nullableList: List?, - val optionalList: Optional>, - val nullableOptionalList: Optional>?) { - override fun toString(): String = buildString { +class UnitTestingClusterNullablesAndOptionalsStruct( + val nullableInt: UInt?, + val optionalInt: Optional, + val nullableOptionalInt: Optional?, + val nullableString: String?, + val optionalString: Optional, + val nullableOptionalString: Optional?, + val nullableStruct: UnitTestingClusterSimpleStruct?, + val optionalStruct: Optional, + val nullableOptionalStruct: Optional?, + val nullableList: List?, + val optionalList: Optional>, + val nullableOptionalList: Optional>? +) { + override fun toString(): String = buildString { append("UnitTestingClusterNullablesAndOptionalsStruct {\n") append("\tnullableInt : $nullableInt\n") append("\toptionalInt : $optionalInt\n") @@ -60,85 +59,85 @@ class UnitTestingClusterNullablesAndOptionalsStruct ( tlvWriter.apply { startStructure(tlvTag) if (nullableInt != null) { - put(ContextSpecificTag(TAG_NULLABLE_INT), nullableInt) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_INT)) - } + put(ContextSpecificTag(TAG_NULLABLE_INT), nullableInt) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_INT)) + } if (optionalInt.isPresent) { - val optoptionalInt = optionalInt.get() - put(ContextSpecificTag(TAG_OPTIONAL_INT), optoptionalInt) - } + val optoptionalInt = optionalInt.get() + put(ContextSpecificTag(TAG_OPTIONAL_INT), optoptionalInt) + } if (nullableOptionalInt != null) { - if (nullableOptionalInt.isPresent) { - val optnullableOptionalInt = nullableOptionalInt.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) - } + if (nullableOptionalInt.isPresent) { + val optnullableOptionalInt = nullableOptionalInt.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) + } if (nullableString != null) { - put(ContextSpecificTag(TAG_NULLABLE_STRING), nullableString) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_STRING)) - } + put(ContextSpecificTag(TAG_NULLABLE_STRING), nullableString) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_STRING)) + } if (optionalString.isPresent) { - val optoptionalString = optionalString.get() - put(ContextSpecificTag(TAG_OPTIONAL_STRING), optoptionalString) - } + val optoptionalString = optionalString.get() + put(ContextSpecificTag(TAG_OPTIONAL_STRING), optoptionalString) + } if (nullableOptionalString != null) { - if (nullableOptionalString.isPresent) { - val optnullableOptionalString = nullableOptionalString.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) - } + if (nullableOptionalString.isPresent) { + val optnullableOptionalString = nullableOptionalString.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) + } if (nullableStruct != null) { - nullableStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), this) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) - } + nullableStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), this) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) + } if (optionalStruct.isPresent) { - val optoptionalStruct = optionalStruct.get() - optoptionalStruct.toTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), this) - } + val optoptionalStruct = optionalStruct.get() + optoptionalStruct.toTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), this) + } if (nullableOptionalStruct != null) { - if (nullableOptionalStruct.isPresent) { - val optnullableOptionalStruct = nullableOptionalStruct.get() - optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) - } + if (nullableOptionalStruct.isPresent) { + val optnullableOptionalStruct = nullableOptionalStruct.get() + optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) + } if (nullableList != null) { - startArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - for (item in nullableList.iterator()) { - put(AnonymousTag, item) + startArray(ContextSpecificTag(TAG_NULLABLE_LIST)) + for (item in nullableList.iterator()) { + put(AnonymousTag, item) + } + endArray() + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_LIST)) } - endArray() - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_LIST)) - } if (optionalList.isPresent) { - val optoptionalList = optionalList.get() - startArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - for (item in optoptionalList.iterator()) { - put(AnonymousTag, item) + val optoptionalList = optionalList.get() + startArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) + for (item in optoptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() } - endArray() - } if (nullableOptionalList != null) { - if (nullableOptionalList.isPresent) { - val optnullableOptionalList = nullableOptionalList.get() - startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - for (item in optnullableOptionalList.iterator()) { - put(AnonymousTag, item) + if (nullableOptionalList.isPresent) { + val optnullableOptionalList = nullableOptionalList.get() + startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + for (item in optnullableOptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) } - endArray() - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - } endStructure() } } @@ -157,114 +156,153 @@ class UnitTestingClusterNullablesAndOptionalsStruct ( private const val TAG_OPTIONAL_LIST = 10 private const val TAG_NULLABLE_OPTIONAL_LIST = 11 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterNullablesAndOptionalsStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNullablesAndOptionalsStruct { tlvReader.enterStructure(tlvTag) - val nullableInt = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_INT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) - null - } - val optionalInt = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_INT))) - } else { - Optional.empty() - } - val nullableOptionalInt = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) - null - } - val nullableString = if (!tlvReader.isNull()) { - tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) - null - } - val optionalString = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) - } else { - Optional.empty() - } - val nullableOptionalString = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) - null - } - val nullableStruct = if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) - null - } - val optionalStruct = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { - Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), tlvReader)) - } else { - Optional.empty() - } - val nullableOptionalStruct = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { - Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) - null - } - val nullableList = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) - null - } - val optionalList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val nullableOptionalList = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - null - } - + val nullableInt = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_INT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) + null + } + val optionalInt = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_INT))) + } else { + Optional.empty() + } + val nullableOptionalInt = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) + null + } + val nullableString = + if (!tlvReader.isNull()) { + tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) + null + } + val optionalString = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) + } else { + Optional.empty() + } + val nullableOptionalString = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) + null + } + val nullableStruct = + if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) + null + } + val optionalStruct = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { + Optional.of( + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_OPTIONAL_STRUCT), + tlvReader + ) + ) + } else { + Optional.empty() + } + val nullableOptionalStruct = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { + Optional.of( + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), + tlvReader + ) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) + null + } + val nullableList = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) + null + } + val optionalList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val nullableOptionalList = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + null + } + tlvReader.exitContainer() - return UnitTestingClusterNullablesAndOptionalsStruct(nullableInt, optionalInt, nullableOptionalInt, nullableString, optionalString, nullableOptionalString, nullableStruct, optionalStruct, nullableOptionalStruct, nullableList, optionalList, nullableOptionalList) + return UnitTestingClusterNullablesAndOptionalsStruct( + nullableInt, + optionalInt, + nullableOptionalInt, + nullableString, + optionalString, + nullableOptionalString, + nullableStruct, + optionalStruct, + nullableOptionalStruct, + nullableList, + optionalList, + nullableOptionalList + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt index 3026a55dc4380c..217991a38b634a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt @@ -17,25 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterSimpleStruct ( - val a: UInt, - val b: Boolean, - val c: UInt, - val d: ByteArray, - val e: String, - val f: UInt, - val g: Float, - val h: Double) { - override fun toString(): String = buildString { +class UnitTestingClusterSimpleStruct( + val a: UInt, + val b: Boolean, + val c: UInt, + val d: ByteArray, + val e: String, + val f: UInt, + val g: Float, + val h: Double +) { + override fun toString(): String = buildString { append("UnitTestingClusterSimpleStruct {\n") append("\ta : $a\n") append("\tb : $b\n") @@ -73,7 +70,7 @@ class UnitTestingClusterSimpleStruct ( private const val TAG_G = 6 private const val TAG_H = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterSimpleStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterSimpleStruct { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) @@ -83,7 +80,7 @@ class UnitTestingClusterSimpleStruct ( val f = tlvReader.getUInt(ContextSpecificTag(TAG_F)) val g = tlvReader.getFloat(ContextSpecificTag(TAG_G)) val h = tlvReader.getDouble(ContextSpecificTag(TAG_H)) - + tlvReader.exitContainer() return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt index 22970640c5eb3c..36da8ea1549865 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt @@ -17,25 +17,24 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterTestFabricScoped ( - val fabricSensitiveInt8u: UInt, - val optionalFabricSensitiveInt8u: Optional, - val nullableFabricSensitiveInt8u: UInt?, - val nullableOptionalFabricSensitiveInt8u: Optional?, - val fabricSensitiveCharString: String, - val fabricSensitiveStruct: UnitTestingClusterSimpleStruct, - val fabricSensitiveInt8uList: List, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class UnitTestingClusterTestFabricScoped( + val fabricSensitiveInt8u: UInt, + val optionalFabricSensitiveInt8u: Optional, + val nullableFabricSensitiveInt8u: UInt?, + val nullableOptionalFabricSensitiveInt8u: Optional?, + val fabricSensitiveCharString: String, + val fabricSensitiveStruct: UnitTestingClusterSimpleStruct, + val fabricSensitiveInt8uList: List, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("UnitTestingClusterTestFabricScoped {\n") append("\tfabricSensitiveInt8u : $fabricSensitiveInt8u\n") append("\toptionalFabricSensitiveInt8u : $optionalFabricSensitiveInt8u\n") @@ -53,22 +52,28 @@ class UnitTestingClusterTestFabricScoped ( startStructure(tlvTag) put(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U), fabricSensitiveInt8u) if (optionalFabricSensitiveInt8u.isPresent) { - val optoptionalFabricSensitiveInt8u = optionalFabricSensitiveInt8u.get() - put(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), optoptionalFabricSensitiveInt8u) - } + val optoptionalFabricSensitiveInt8u = optionalFabricSensitiveInt8u.get() + put( + ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), + optoptionalFabricSensitiveInt8u + ) + } if (nullableFabricSensitiveInt8u != null) { - put(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U), nullableFabricSensitiveInt8u) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - } + put(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U), nullableFabricSensitiveInt8u) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + } if (nullableOptionalFabricSensitiveInt8u != null) { - if (nullableOptionalFabricSensitiveInt8u.isPresent) { - val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), optnullableOptionalFabricSensitiveInt8u) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - } + if (nullableOptionalFabricSensitiveInt8u.isPresent) { + val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() + put( + ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), + optnullableOptionalFabricSensitiveInt8u + ) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + } put(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING), fabricSensitiveCharString) fabricSensitiveStruct.toTlv(ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), this) startArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) @@ -91,44 +96,66 @@ class UnitTestingClusterTestFabricScoped ( private const val TAG_FABRIC_SENSITIVE_INT8U_LIST = 7 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestFabricScoped { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScoped { tlvReader.enterStructure(tlvTag) val fabricSensitiveInt8u = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U)) - val optionalFabricSensitiveInt8u = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - val nullableFabricSensitiveInt8u = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - null - } - val nullableOptionalFabricSensitiveInt8u = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - null - } - val fabricSensitiveCharString = tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) - val fabricSensitiveStruct = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), tlvReader) - val fabricSensitiveInt8uList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val optionalFabricSensitiveInt8u = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) + } else { + Optional.empty() + } + val nullableFabricSensitiveInt8u = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + null + } + val nullableOptionalFabricSensitiveInt8u = + if (!tlvReader.isNull()) { + if ( + tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + ) { + Optional.of( + tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + null + } + val fabricSensitiveCharString = + tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) + val fabricSensitiveStruct = + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), + tlvReader + ) + val fabricSensitiveInt8uList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return UnitTestingClusterTestFabricScoped(fabricSensitiveInt8u, optionalFabricSensitiveInt8u, nullableFabricSensitiveInt8u, nullableOptionalFabricSensitiveInt8u, fabricSensitiveCharString, fabricSensitiveStruct, fabricSensitiveInt8uList, fabricIndex) + return UnitTestingClusterTestFabricScoped( + fabricSensitiveInt8u, + optionalFabricSensitiveInt8u, + nullableFabricSensitiveInt8u, + nullableOptionalFabricSensitiveInt8u, + fabricSensitiveCharString, + fabricSensitiveStruct, + fabricSensitiveInt8uList, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt index 1f823ba5cb92f9..91afedb93a404f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterTestListStructOctet ( - val member1: ULong, - val member2: ByteArray) { - override fun toString(): String = buildString { +class UnitTestingClusterTestListStructOctet(val member1: ULong, val member2: ByteArray) { + override fun toString(): String = buildString { append("UnitTestingClusterTestListStructOctet {\n") append("\tmember1 : $member1\n") append("\tmember2 : $member2\n") @@ -49,11 +43,11 @@ class UnitTestingClusterTestListStructOctet ( private const val TAG_MEMBER1 = 0 private const val TAG_MEMBER2 = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestListStructOctet { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestListStructOctet { tlvReader.enterStructure(tlvTag) val member1 = tlvReader.getULong(ContextSpecificTag(TAG_MEMBER1)) val member2 = tlvReader.getByteArray(ContextSpecificTag(TAG_MEMBER2)) - + tlvReader.exitContainer() return UnitTestingClusterTestListStructOctet(member1, member2) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt index 02509a81a9dbbc..1cfbb532f5abaf 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UserLabelClusterLabelStruct ( - val label: String, - val value: String) { - override fun toString(): String = buildString { +class UserLabelClusterLabelStruct(val label: String, val value: String) { + override fun toString(): String = buildString { append("UserLabelClusterLabelStruct {\n") append("\tlabel : $label\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class UserLabelClusterLabelStruct ( private const val TAG_LABEL = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UserLabelClusterLabelStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UserLabelClusterLabelStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return UserLabelClusterLabelStruct(label, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt index 6c02e602d0f2cf..c42cda3ef21f13 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt @@ -17,195 +17,154 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccessControlCluster(private val controller: MatterController, private val endpointId: UShort) {class AclAttribute( - val value: List - ) +class AccessControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AclAttribute(val value: List) sealed class AclAttributeSubscriptionState { - data class Success( - val value: List - ) : AclAttributeSubscriptionState() - + data class Success(val value: List) : + AclAttributeSubscriptionState() + data class Error(val exception: Exception) : AclAttributeSubscriptionState() - object SubscriptionEstablished : AclAttributeSubscriptionState() - } -class ExtensionAttribute( - val value: List? - ) + object SubscriptionEstablished : AclAttributeSubscriptionState() + } + + class ExtensionAttribute(val value: List?) sealed class ExtensionAttributeSubscriptionState { - data class Success( - val value: List? - ) : ExtensionAttributeSubscriptionState() - + data class Success(val value: List?) : + ExtensionAttributeSubscriptionState() + data class Error(val exception: Exception) : ExtensionAttributeSubscriptionState() - object SubscriptionEstablished : ExtensionAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ExtensionAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readAclAttribute(): AclAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readAclAttribute(): AclAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acl attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acl attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AclAttribute(decodedValue) } suspend fun writeAclAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -227,7 +186,7 @@ suspend fun readAclAttribute(): AclAttribute {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAclAttribute( @@ -235,45 +194,48 @@ suspend fun readAclAttribute(): AclAttribute {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AclAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AclAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acl attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Acl attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(AclAttributeSubscriptionState.Success(decodedValue)) } @@ -281,81 +243,74 @@ suspend fun readAclAttribute(): AclAttribute {val ATTRIBUTE_ID: UInt = 0u emit(AclAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readExtensionAttribute(): ExtensionAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readExtensionAttribute(): ExtensionAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Extension attribute not found in response" - } + } + + requireNotNull(attributeData) { "Extension attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ExtensionAttribute(decodedValue) } suspend fun writeExtensionAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -377,7 +332,7 @@ suspend fun readExtensionAttribute(): ExtensionAttribute {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeExtensionAttribute( @@ -385,97 +340,97 @@ suspend fun readExtensionAttribute(): ExtensionAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ExtensionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ExtensionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Extension attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Extension attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ExtensionAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + AccessControlClusterAccessControlExtensionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ExtensionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ExtensionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Subjectsperaccesscontrolentry attribute not found in response" + } + + requireNotNull(attributeData) { + "Subjectsperaccesscontrolentry attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -484,34 +439,38 @@ suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Subjectsperaccesscontrolentry attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Subjectsperaccesscontrolentry attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -524,44 +483,37 @@ suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTargetsPerAccessControlEntryAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetsperaccesscontrolentry attribute not found in response" - } + } + + requireNotNull(attributeData) { "Targetsperaccesscontrolentry attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -570,34 +522,38 @@ suspend fun readTargetsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetsperaccesscontrolentry attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Targetsperaccesscontrolentry attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -610,44 +566,39 @@ suspend fun readTargetsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_I emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAccessControlEntriesPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAccessControlEntriesPerFabricAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accesscontrolentriesperfabric attribute not found in response" + } + + requireNotNull(attributeData) { + "Accesscontrolentriesperfabric attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -656,34 +607,38 @@ suspend fun readAccessControlEntriesPerFabricAttribute(): UShort {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accesscontrolentriesperfabric attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accesscontrolentriesperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -696,49 +651,43 @@ suspend fun readAccessControlEntriesPerFabricAttribute(): UShort {val ATTRIBUTE_ emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -748,45 +697,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -794,49 +748,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -846,45 +794,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -892,49 +845,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -944,45 +891,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -990,49 +940,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1042,45 +986,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1088,44 +1035,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1134,35 +1074,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1174,44 +1116,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1220,34 +1155,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1260,7 +1199,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt index 8bd65be952b931..d7dcb095c61498 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt @@ -17,114 +17,85 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccountLoginCluster(private val controller: MatterController, private val endpointId: UShort) { - class GetSetupPINResponse( - val setupPIN: String - ) -class GeneratedCommandListAttribute( - val value: List - ) +class AccountLoginCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GetSetupPINResponse(val setupPIN: String) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun getSetupPIN(tempAccountIdentifier: String - ,timedInvokeTimeout: Duration): GetSetupPINResponse { + suspend fun getSetupPIN( + tempAccountIdentifier: String, + timedInvokeTimeout: Duration + ): GetSetupPINResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TEMP_ACCOUNT_IDENTIFIER_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TEMP_ACCOUNT_IDENTIFIER_REQ), tempAccountIdentifier) + tlvWriter.put(ContextSpecificTag(TAG_TEMP_ACCOUNT_IDENTIFIER_REQ), tempAccountIdentifier) tlvWriter.endStructure() val request: InvokeRequest = @@ -141,38 +112,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_SETUP_P_I_N: Int = 0 var setupPIN_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_SETUP_P_I_N)) {setupPIN_decoded = tlvReader.getString(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_SETUP_P_I_N)) { + setupPIN_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (setupPIN_decoded == null) { - throw IllegalStateException("setupPIN not found in TLV") + throw IllegalStateException("setupPIN not found in TLV") } - tlvReader.exitContainer() - return GetSetupPINResponse( - setupPIN_decoded - ) + return GetSetupPINResponse(setupPIN_decoded) } - suspend fun login(tempAccountIdentifier: String - ,setupPIN: String - ,node: ULong? - ,timedInvokeTimeout: Duration) { + suspend fun login( + tempAccountIdentifier: String, + setupPIN: String, + node: ULong?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -185,9 +150,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_SETUP_P_I_N_REQ), setupPIN) val TAG_NODE_REQ: Int = 2 - node?.let { - tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) - } + node?.let { tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) } tlvWriter.endStructure() val request: InvokeRequest = @@ -201,17 +164,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun logout(node: ULong? - ,timedInvokeTimeout: Duration) { + suspend fun logout(node: ULong?, timedInvokeTimeout: Duration) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NODE_REQ: Int = 0 - node?.let { - tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) - } + node?.let { tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) } tlvWriter.endStructure() val request: InvokeRequest = @@ -224,47 +184,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -274,45 +228,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -320,49 +279,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -372,45 +325,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -418,49 +376,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -470,45 +422,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -516,49 +471,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -568,45 +517,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -614,44 +566,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -660,35 +605,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -700,44 +647,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -746,34 +686,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -786,7 +730,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt index 77cb5b4c8feca0..5f44f5c6a99747 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt @@ -17,130 +17,97 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActionsCluster(private val controller: MatterController, private val endpointId: UShort) {class ActionListAttribute( - val value: List - ) +class ActionsCluster(private val controller: MatterController, private val endpointId: UShort) { + class ActionListAttribute(val value: List) sealed class ActionListAttributeSubscriptionState { - data class Success( - val value: List - ) : ActionListAttributeSubscriptionState() - + data class Success(val value: List) : + ActionListAttributeSubscriptionState() + data class Error(val exception: Exception) : ActionListAttributeSubscriptionState() - object SubscriptionEstablished : ActionListAttributeSubscriptionState() - } -class EndpointListsAttribute( - val value: List - ) + object SubscriptionEstablished : ActionListAttributeSubscriptionState() + } + + class EndpointListsAttribute(val value: List) sealed class EndpointListsAttributeSubscriptionState { - data class Success( - val value: List - ) : EndpointListsAttributeSubscriptionState() - + data class Success(val value: List) : + EndpointListsAttributeSubscriptionState() + data class Error(val exception: Exception) : EndpointListsAttributeSubscriptionState() - object SubscriptionEstablished : EndpointListsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : EndpointListsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun instantAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun instantAction( + actionID: UShort, + invokeID: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -150,9 +117,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -166,10 +131,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun instantActionWithTransition(actionID: UShort - ,invokeID: UInt? - ,transitionTime: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun instantActionWithTransition( + actionID: UShort, + invokeID: UInt?, + transitionTime: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -179,12 +146,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_TRANSITION_TIME_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -198,9 +163,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun startAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -210,9 +173,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -226,10 +187,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startActionWithDuration(actionID: UShort - ,invokeID: UInt? - ,duration: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun startActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -239,12 +202,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -258,9 +219,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stopAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun stopAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -270,9 +229,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -286,9 +243,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun pauseAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -298,9 +253,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -314,10 +267,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseActionWithDuration(actionID: UShort - ,invokeID: UInt? - ,duration: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun pauseActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -327,12 +282,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -346,9 +299,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun resumeAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun resumeAction( + actionID: UShort, + invokeID: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -358,9 +313,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -374,9 +327,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun enableAction( + actionID: UShort, + invokeID: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 8u val tlvWriter = TlvWriter() @@ -386,9 +341,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -402,10 +355,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableActionWithDuration(actionID: UShort - ,invokeID: UInt? - ,duration: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun enableActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -415,12 +370,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -434,9 +387,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun disableAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun disableAction( + actionID: UShort, + invokeID: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 10u val tlvWriter = TlvWriter() @@ -446,9 +401,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -462,10 +415,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun disableActionWithDuration(actionID: UShort - ,invokeID: UInt? - ,duration: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun disableActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 11u val tlvWriter = TlvWriter() @@ -475,12 +430,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -493,47 +446,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readActionListAttribute(): ActionListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActionListAttribute(): ActionListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actionlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Actionlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ActionListAttribute(decodedValue) } @@ -543,45 +490,48 @@ suspend fun readActionListAttribute(): ActionListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActionListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActionListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actionlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Actionlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ActionListAttributeSubscriptionState.Success(decodedValue)) } @@ -589,49 +539,43 @@ suspend fun readActionListAttribute(): ActionListAttribute {val ATTRIBUTE_ID: UI emit(ActionListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEndpointListsAttribute(): EndpointListsAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEndpointListsAttribute(): EndpointListsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endpointlists attribute not found in response" - } + } + + requireNotNull(attributeData) { "Endpointlists attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EndpointListsAttribute(decodedValue) } @@ -641,45 +585,48 @@ suspend fun readEndpointListsAttribute(): EndpointListsAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EndpointListsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EndpointListsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endpointlists attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Endpointlists attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(EndpointListsAttributeSubscriptionState.Success(decodedValue)) } @@ -687,47 +634,41 @@ suspend fun readEndpointListsAttribute(): EndpointListsAttribute {val ATTRIBUTE_ emit(EndpointListsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetupURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSetupURLAttribute(): String? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setupurl attribute not found in response" - } + } + + requireNotNull(attributeData) { "Setupurl attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -737,96 +678,90 @@ suspend fun readSetupURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setupurl attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Setupurl attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -836,45 +771,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -882,49 +822,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -934,45 +868,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -980,49 +919,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1032,45 +965,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1078,49 +1014,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1130,45 +1060,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1176,44 +1109,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1222,35 +1148,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1262,44 +1190,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1308,34 +1229,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1348,7 +1273,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt index 73fbba68b06ac4..daa2d6a7bdf0f6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt @@ -17,132 +17,105 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActivatedCarbonFilterMonitoringCluster(private val controller: MatterController, private val endpointId: UShort) {class LastChangedTimeAttribute( - val value: UInt? - ) +class ActivatedCarbonFilterMonitoringCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LastChangedTimeAttribute(val value: UInt?) sealed class LastChangedTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LastChangedTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : LastChangedTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : LastChangedTimeAttributeSubscriptionState() - object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() - } -class ReplacementProductListAttribute( + object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() + } + + class ReplacementProductListAttribute( val value: List? ) sealed class ReplacementProductListAttributeSubscriptionState { data class Success( - val value: List? + val value: List? ) : ReplacementProductListAttributeSubscriptionState() - + data class Error(val exception: Exception) : ReplacementProductListAttributeSubscriptionState() - object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCondition(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,45 +128,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readConditionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Condition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Condition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -203,94 +170,88 @@ suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Condition attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Condition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDegradationDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Degradationdirection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -300,91 +261,86 @@ suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Degradationdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readChangeIndicationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Changeindication attribute not found in response" - } + } + + requireNotNull(attributeData) { "Changeindication attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -393,34 +349,38 @@ suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Changeindication attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Changeindication attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -433,47 +393,41 @@ suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInPlaceIndicatorAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in response" - } + } + + requireNotNull(attributeData) { "Inplaceindicator attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -483,123 +437,115 @@ suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Inplaceindicator attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastchangedtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastChangedTimeAttribute(decodedValue) } - suspend fun writeLastChangedTimeAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -621,7 +567,7 @@ suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLastChangedTimeAttribute( @@ -629,105 +575,106 @@ suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastChangedTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastChangedTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastchangedtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LastChangedTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LastChangedTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastChangedTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Replacementproductlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ReplacementProductListAttribute(decodedValue) } @@ -737,102 +684,103 @@ suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ReplacementProductListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ReplacementProductListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Replacementproductlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ReplacementProductListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ReplacementProductListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ReplacementProductListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -842,45 +790,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -888,49 +841,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -940,45 +887,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -986,49 +938,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1038,45 +984,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1084,49 +1033,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1136,45 +1079,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1182,44 +1128,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1228,35 +1167,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1268,44 +1209,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1314,34 +1248,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1354,7 +1292,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt index 0d51abdb78e597..4fd1bd91dacbe3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt @@ -17,133 +17,101 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AdministratorCommissioningCluster(private val controller: MatterController, private val endpointId: UShort) {class AdminFabricIndexAttribute( - val value: UByte? - ) +class AdministratorCommissioningCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AdminFabricIndexAttribute(val value: UByte?) sealed class AdminFabricIndexAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : AdminFabricIndexAttributeSubscriptionState() - + data class Success(val value: UByte?) : AdminFabricIndexAttributeSubscriptionState() + data class Error(val exception: Exception) : AdminFabricIndexAttributeSubscriptionState() - object SubscriptionEstablished : AdminFabricIndexAttributeSubscriptionState() - } -class AdminVendorIdAttribute( - val value: UShort? - ) + object SubscriptionEstablished : AdminFabricIndexAttributeSubscriptionState() + } + + class AdminVendorIdAttribute(val value: UShort?) sealed class AdminVendorIdAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : AdminVendorIdAttributeSubscriptionState() - + data class Success(val value: UShort?) : AdminVendorIdAttributeSubscriptionState() + data class Error(val exception: Exception) : AdminVendorIdAttributeSubscriptionState() - object SubscriptionEstablished : AdminVendorIdAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AdminVendorIdAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun openCommissioningWindow(commissioningTimeout: UShort - ,PAKEPasscodeVerifier: ByteArray - ,discriminator: UShort - ,iterations: UInt - ,salt: ByteArray - ,timedInvokeTimeout: Duration) { + suspend fun openCommissioningWindow( + commissioningTimeout: UShort, + PAKEPasscodeVerifier: ByteArray, + discriminator: UShort, + iterations: UInt, + salt: ByteArray, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -162,7 +130,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ITERATIONS_REQ), iterations) val TAG_SALT_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_SALT_REQ), salt) + tlvWriter.put(ContextSpecificTag(TAG_SALT_REQ), salt) tlvWriter.endStructure() val request: InvokeRequest = @@ -176,15 +144,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun openBasicCommissioningWindow(commissioningTimeout: UShort - ,timedInvokeTimeout: Duration) { + suspend fun openBasicCommissioningWindow( + commissioningTimeout: UShort, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_COMMISSIONING_TIMEOUT_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_COMMISSIONING_TIMEOUT_REQ), commissioningTimeout) + tlvWriter.put(ContextSpecificTag(TAG_COMMISSIONING_TIMEOUT_REQ), commissioningTimeout) tlvWriter.endStructure() val request: InvokeRequest = @@ -202,7 +172,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -215,42 +185,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readWindowStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWindowStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windowstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Windowstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -259,35 +222,37 @@ suspend fun readWindowStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windowstatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Windowstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -299,48 +264,42 @@ suspend fun readWindowStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Adminfabricindex attribute not found in response" - } + } + + requireNotNull(attributeData) { "Adminfabricindex attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return AdminFabricIndexAttribute(decodedValue) } @@ -350,96 +309,92 @@ suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AdminFabricIndexAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AdminFabricIndexAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Adminfabricindex attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Adminfabricindex attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AdminFabricIndexAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AdminFabricIndexAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AdminFabricIndexAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Adminvendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Adminvendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return AdminVendorIdAttribute(decodedValue) } @@ -449,97 +404,91 @@ suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AdminVendorIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AdminVendorIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Adminvendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Adminvendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AdminVendorIdAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AdminVendorIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AdminVendorIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -549,45 +498,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -595,49 +549,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -647,45 +595,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -693,49 +646,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -745,45 +692,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -791,49 +741,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -843,45 +787,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -889,44 +836,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -935,35 +875,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -975,44 +917,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1021,34 +956,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1061,7 +1000,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt index 7622ac8f893d32..b2c558f45df037 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt @@ -17,136 +17,93 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class AirQualityCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class AirQualityCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readAirQualityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readAirQualityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Airquality attribute not found in response" - } + } + + requireNotNull(attributeData) { "Airquality attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -155,35 +112,37 @@ suspend fun readAirQualityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Airquality attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Airquality attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,49 +154,43 @@ suspend fun readAirQualityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -247,45 +200,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -293,49 +251,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -345,45 +297,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -391,49 +348,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -443,45 +394,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -489,49 +443,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -541,45 +489,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -587,44 +538,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -633,35 +577,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -673,44 +619,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -719,34 +658,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -759,7 +702,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt index 880e6385833234..ed62272114e72a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt @@ -17,165 +17,122 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ApplicationBasicCluster(private val controller: MatterController, private val endpointId: UShort) {class ApplicationAttribute( - val value: ApplicationBasicClusterApplicationStruct - ) +class ApplicationBasicCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ApplicationAttribute(val value: ApplicationBasicClusterApplicationStruct) sealed class ApplicationAttributeSubscriptionState { - data class Success( - val value: ApplicationBasicClusterApplicationStruct - ) : ApplicationAttributeSubscriptionState() - + data class Success(val value: ApplicationBasicClusterApplicationStruct) : + ApplicationAttributeSubscriptionState() + data class Error(val exception: Exception) : ApplicationAttributeSubscriptionState() - object SubscriptionEstablished : ApplicationAttributeSubscriptionState() - } -class AllowedVendorListAttribute( - val value: List - ) + object SubscriptionEstablished : ApplicationAttributeSubscriptionState() + } + + class AllowedVendorListAttribute(val value: List) sealed class AllowedVendorListAttributeSubscriptionState { - data class Success( - val value: List - ) : AllowedVendorListAttributeSubscriptionState() - + data class Success(val value: List) : AllowedVendorListAttributeSubscriptionState() + data class Error(val exception: Exception) : AllowedVendorListAttributeSubscriptionState() - object SubscriptionEstablished : AllowedVendorListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AllowedVendorListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readVendorNameAttribute(): String? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -185,94 +142,88 @@ suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readVendorIDAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -282,91 +233,84 @@ suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApplicationNameAttribute(): String {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readApplicationNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Applicationname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -375,34 +319,38 @@ suspend fun readApplicationNameAttribute(): String {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationname attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Applicationname attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -415,47 +363,41 @@ suspend fun readApplicationNameAttribute(): String {val ATTRIBUTE_ID: UInt = 2u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductIDAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -465,90 +407,84 @@ suspend fun readProductIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApplicationAttribute(): ApplicationAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readApplicationAttribute(): ApplicationAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Application attribute not found in response" - } + } + + requireNotNull(attributeData) { "Application attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationBasicClusterApplicationStruct = ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: ApplicationBasicClusterApplicationStruct = + ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) return ApplicationAttribute(decodedValue) } @@ -558,39 +494,42 @@ suspend fun readApplicationAttribute(): ApplicationAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ApplicationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ApplicationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Application attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Application attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationBasicClusterApplicationStruct = ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: ApplicationBasicClusterApplicationStruct = + ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) emit(ApplicationAttributeSubscriptionState.Success(decodedValue)) } @@ -598,44 +537,37 @@ suspend fun readApplicationAttribute(): ApplicationAttribute {val ATTRIBUTE_ID: emit(ApplicationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Status attribute not found in response" - } + } + + requireNotNull(attributeData) { "Status attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -644,35 +576,37 @@ suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Status attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Status attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -684,44 +618,37 @@ suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApplicationVersionAttribute(): String {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readApplicationVersionAttribute(): String { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Applicationversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -730,34 +657,38 @@ suspend fun readApplicationVersionAttribute(): String {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Applicationversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -770,49 +701,43 @@ suspend fun readApplicationVersionAttribute(): String {val ATTRIBUTE_ID: UInt = emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Allowedvendorlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Allowedvendorlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AllowedVendorListAttribute(decodedValue) } @@ -822,45 +747,50 @@ suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AllowedVendorListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AllowedVendorListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Allowedvendorlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Allowedvendorlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AllowedVendorListAttributeSubscriptionState.Success(decodedValue)) } @@ -868,49 +798,43 @@ suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute {val AT emit(AllowedVendorListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -920,45 +844,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -966,49 +895,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1018,45 +941,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1064,49 +992,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1116,45 +1038,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1162,49 +1087,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1214,45 +1133,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1260,44 +1182,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1306,35 +1221,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1346,44 +1263,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1392,34 +1302,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1432,7 +1346,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt index 5045bf8de2e5ee..7d9f650c50480b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt @@ -17,149 +17,110 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ApplicationLauncherCluster(private val controller: MatterController, private val endpointId: UShort) { - class LauncherResponse( - val status: UByte, - val data: ByteArray? - ) -class CatalogListAttribute( - val value: List? - ) +class ApplicationLauncherCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LauncherResponse(val status: UByte, val data: ByteArray?) + + class CatalogListAttribute(val value: List?) sealed class CatalogListAttributeSubscriptionState { - data class Success( - val value: List? - ) : CatalogListAttributeSubscriptionState() - + data class Success(val value: List?) : CatalogListAttributeSubscriptionState() + data class Error(val exception: Exception) : CatalogListAttributeSubscriptionState() - object SubscriptionEstablished : CatalogListAttributeSubscriptionState() - } -class CurrentAppAttribute( - val value: ApplicationLauncherClusterApplicationEPStruct? - ) + object SubscriptionEstablished : CatalogListAttributeSubscriptionState() + } + + class CurrentAppAttribute(val value: ApplicationLauncherClusterApplicationEPStruct?) sealed class CurrentAppAttributeSubscriptionState { - data class Success( - val value: ApplicationLauncherClusterApplicationEPStruct? - ) : CurrentAppAttributeSubscriptionState() - + data class Success(val value: ApplicationLauncherClusterApplicationEPStruct?) : + CurrentAppAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentAppAttributeSubscriptionState() - object SubscriptionEstablished : CurrentAppAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : CurrentAppAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun launchApp(application: ApplicationLauncherClusterApplicationStruct? - ,data: ByteArray? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun launchApp( + application: ApplicationLauncherClusterApplicationStruct?, + data: ByteArray?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_APPLICATION_REQ: Int = 0 - application?.let { - application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) - } + application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } val TAG_DATA_REQ: Int = 1 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } tlvWriter.endStructure() val request: InvokeRequest = @@ -176,63 +137,54 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } - suspend fun stopApp(application: ApplicationLauncherClusterApplicationStruct? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun stopApp( + application: ApplicationLauncherClusterApplicationStruct?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_APPLICATION_REQ: Int = 0 - application?.let { - application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) - } + application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } tlvWriter.endStructure() val request: InvokeRequest = @@ -249,63 +201,54 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } - suspend fun hideApp(application: ApplicationLauncherClusterApplicationStruct? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun hideApp( + application: ApplicationLauncherClusterApplicationStruct?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_APPLICATION_REQ: Int = 0 - application?.let { - application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) - } + application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } tlvWriter.endStructure() val request: InvokeRequest = @@ -322,96 +265,81 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } -suspend fun readCatalogListAttribute(): CatalogListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCatalogListAttribute(): CatalogListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cataloglist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Cataloglist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return CatalogListAttribute(decodedValue) } @@ -421,105 +349,99 @@ suspend fun readCatalogListAttribute(): CatalogListAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CatalogListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CatalogListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cataloglist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Cataloglist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(CatalogListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(CatalogListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CatalogListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentAppAttribute(): CurrentAppAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentAppAttribute(): CurrentAppAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentapp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentapp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentAppAttribute(decodedValue) } @@ -529,101 +451,95 @@ suspend fun readCurrentAppAttribute(): CurrentAppAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentAppAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentAppAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentapp attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentapp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentAppAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentAppAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentAppAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -633,45 +549,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -679,49 +600,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -731,45 +646,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -777,49 +697,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -829,45 +743,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -875,49 +792,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -927,45 +838,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -973,44 +887,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1019,35 +926,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1059,44 +968,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1105,34 +1007,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1145,7 +1051,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt index c038970d786898..d5a58d5c07ca1f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt @@ -17,123 +17,89 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AudioOutputCluster(private val controller: MatterController, private val endpointId: UShort) {class OutputListAttribute( - val value: List - ) +class AudioOutputCluster(private val controller: MatterController, private val endpointId: UShort) { + class OutputListAttribute(val value: List) sealed class OutputListAttributeSubscriptionState { - data class Success( - val value: List - ) : OutputListAttributeSubscriptionState() - + data class Success(val value: List) : + OutputListAttributeSubscriptionState() + data class Error(val exception: Exception) : OutputListAttributeSubscriptionState() - object SubscriptionEstablished : OutputListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OutputListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun selectOutput(index: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun selectOutput(index: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) tlvWriter.endStructure() val request: InvokeRequest = @@ -147,9 +113,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun renameOutput(index: UByte - ,name: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun renameOutput(index: UByte, name: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -159,7 +123,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) val TAG_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) + tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) tlvWriter.endStructure() val request: InvokeRequest = @@ -172,47 +136,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readOutputListAttribute(): OutputListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOutputListAttribute(): OutputListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outputlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Outputlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return OutputListAttribute(decodedValue) } @@ -222,45 +180,48 @@ suspend fun readOutputListAttribute(): OutputListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OutputListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OutputListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outputlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Outputlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(OutputListAttributeSubscriptionState.Success(decodedValue)) } @@ -268,44 +229,37 @@ suspend fun readOutputListAttribute(): OutputListAttribute {val ATTRIBUTE_ID: UI emit(OutputListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentOutputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentOutputAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentoutput attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentoutput attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -314,35 +268,37 @@ suspend fun readCurrentOutputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentoutput attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentoutput attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -354,49 +310,43 @@ suspend fun readCurrentOutputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -406,45 +356,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -452,49 +407,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -504,45 +453,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -550,49 +504,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -602,45 +550,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -648,49 +599,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -700,45 +645,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -746,44 +694,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -792,35 +733,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -832,44 +775,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -878,34 +814,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -918,7 +858,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt index e733a38744d421..a0b361cdbb2400 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt @@ -17,201 +17,152 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BallastConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class IntrinsicBallastFactorAttribute( - val value: UByte? - ) +class BallastConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class IntrinsicBallastFactorAttribute(val value: UByte?) sealed class IntrinsicBallastFactorAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : IntrinsicBallastFactorAttributeSubscriptionState() - + data class Success(val value: UByte?) : IntrinsicBallastFactorAttributeSubscriptionState() + data class Error(val exception: Exception) : IntrinsicBallastFactorAttributeSubscriptionState() - object SubscriptionEstablished : IntrinsicBallastFactorAttributeSubscriptionState() - } -class BallastFactorAdjustmentAttribute( - val value: UByte? - ) + object SubscriptionEstablished : IntrinsicBallastFactorAttributeSubscriptionState() + } + + class BallastFactorAdjustmentAttribute(val value: UByte?) sealed class BallastFactorAdjustmentAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : BallastFactorAdjustmentAttributeSubscriptionState() - - data class Error(val exception: Exception) : BallastFactorAdjustmentAttributeSubscriptionState() - - object SubscriptionEstablished : BallastFactorAdjustmentAttributeSubscriptionState() - } -class LampRatedHoursAttribute( - val value: UInt? - ) + data class Success(val value: UByte?) : BallastFactorAdjustmentAttributeSubscriptionState() + + data class Error(val exception: Exception) : + BallastFactorAdjustmentAttributeSubscriptionState() + + object SubscriptionEstablished : BallastFactorAdjustmentAttributeSubscriptionState() + } + + class LampRatedHoursAttribute(val value: UInt?) sealed class LampRatedHoursAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LampRatedHoursAttributeSubscriptionState() - + data class Success(val value: UInt?) : LampRatedHoursAttributeSubscriptionState() + data class Error(val exception: Exception) : LampRatedHoursAttributeSubscriptionState() - object SubscriptionEstablished : LampRatedHoursAttributeSubscriptionState() - } -class LampBurnHoursAttribute( - val value: UInt? - ) + object SubscriptionEstablished : LampRatedHoursAttributeSubscriptionState() + } + + class LampBurnHoursAttribute(val value: UInt?) sealed class LampBurnHoursAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LampBurnHoursAttributeSubscriptionState() - + data class Success(val value: UInt?) : LampBurnHoursAttributeSubscriptionState() + data class Error(val exception: Exception) : LampBurnHoursAttributeSubscriptionState() - object SubscriptionEstablished : LampBurnHoursAttributeSubscriptionState() - } -class LampBurnHoursTripPointAttribute( - val value: UInt? - ) + object SubscriptionEstablished : LampBurnHoursAttributeSubscriptionState() + } + + class LampBurnHoursTripPointAttribute(val value: UInt?) sealed class LampBurnHoursTripPointAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LampBurnHoursTripPointAttributeSubscriptionState() - + data class Success(val value: UInt?) : LampBurnHoursTripPointAttributeSubscriptionState() + data class Error(val exception: Exception) : LampBurnHoursTripPointAttributeSubscriptionState() - object SubscriptionEstablished : LampBurnHoursTripPointAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LampBurnHoursTripPointAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readPhysicalMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readPhysicalMinLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalminlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Physicalminlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -220,34 +171,38 @@ suspend fun readPhysicalMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalminlevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalminlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -260,44 +215,37 @@ suspend fun readPhysicalMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhysicalMaxLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalmaxlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Physicalmaxlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -306,34 +254,38 @@ suspend fun readPhysicalMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalmaxlevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalmaxlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -346,47 +298,41 @@ suspend fun readPhysicalMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBallastStatusAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBallastStatusAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ballaststatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ballaststatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -396,114 +342,103 @@ suspend fun readBallastStatusAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ballaststatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Ballaststatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeMinLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeMinLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -525,7 +460,7 @@ suspend fun readMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinLevelAttribute( @@ -533,35 +468,37 @@ suspend fun readMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -573,67 +510,56 @@ suspend fun readMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeMaxLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeMaxLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -655,7 +581,7 @@ suspend fun readMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMaxLevelAttribute( @@ -663,35 +589,37 @@ suspend fun readMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -703,76 +631,69 @@ suspend fun readMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribute {val ATTRIBUTE_ID: UInt = 20u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Intrinsicballastfactor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Intrinsicballastfactor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return IntrinsicBallastFactorAttribute(decodedValue) } suspend fun writeIntrinsicBallastFactorAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -794,7 +715,7 @@ suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribu throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeIntrinsicBallastFactorAttribute( @@ -802,128 +723,123 @@ suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntrinsicBallastFactorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntrinsicBallastFactorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Intrinsicballastfactor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Intrinsicballastfactor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(IntrinsicBallastFactorAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(IntrinsicBallastFactorAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(IntrinsicBallastFactorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttribute {val ATTRIBUTE_ID: UInt = 21u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttribute { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ballastfactoradjustment attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ballastfactoradjustment attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BallastFactorAdjustmentAttribute(decodedValue) } suspend fun writeBallastFactorAdjustmentAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -945,7 +861,7 @@ suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttri throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBallastFactorAdjustmentAttribute( @@ -953,96 +869,91 @@ suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BallastFactorAdjustmentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BallastFactorAdjustmentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ballastfactoradjustment attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ballastfactoradjustment attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BallastFactorAdjustmentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BallastFactorAdjustmentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BallastFactorAdjustmentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampQuantityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampQuantityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampquantity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampquantity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1051,35 +962,37 @@ suspend fun readLampQuantityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampquantity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lampquantity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1091,71 +1004,61 @@ suspend fun readLampQuantityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampTypeAttribute(): String? {val ATTRIBUTE_ID: UInt = 48u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampTypeAttribute(): String? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lamptype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lamptype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLampTypeAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampTypeAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1177,7 +1080,7 @@ suspend fun readLampTypeAttribute(): String? {val ATTRIBUTE_ID: UInt = 48u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampTypeAttribute( @@ -1185,118 +1088,108 @@ suspend fun readLampTypeAttribute(): String? {val ATTRIBUTE_ID: UInt = 48u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lamptype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lamptype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampManufacturerAttribute(): String? {val ATTRIBUTE_ID: UInt = 49u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampManufacturerAttribute(): String? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampmanufacturer attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampmanufacturer attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLampManufacturerAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampManufacturerAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1318,7 +1211,7 @@ suspend fun readLampManufacturerAttribute(): String? {val ATTRIBUTE_ID: UInt = 4 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampManufacturerAttribute( @@ -1326,123 +1219,115 @@ suspend fun readLampManufacturerAttribute(): String? {val ATTRIBUTE_ID: UInt = 4 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampmanufacturer attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lampmanufacturer attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute {val ATTRIBUTE_ID: UInt = 50u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampratedhours attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampratedhours attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LampRatedHoursAttribute(decodedValue) } - suspend fun writeLampRatedHoursAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampRatedHoursAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1464,7 +1349,7 @@ suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampRatedHoursAttribute( @@ -1472,128 +1357,120 @@ suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LampRatedHoursAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LampRatedHoursAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampratedhours attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lampratedhours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LampRatedHoursAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LampRatedHoursAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LampRatedHoursAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute {val ATTRIBUTE_ID: UInt = 51u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampburnhours attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampburnhours attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LampBurnHoursAttribute(decodedValue) } - suspend fun writeLampBurnHoursAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampBurnHoursAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1615,7 +1492,7 @@ suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampBurnHoursAttribute( @@ -1623,123 +1500,113 @@ suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LampBurnHoursAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LampBurnHoursAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampburnhours attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lampburnhours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LampBurnHoursAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LampBurnHoursAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LampBurnHoursAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampAlarmModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 52u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampAlarmModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampalarmmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampalarmmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLampAlarmModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampAlarmModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1761,7 +1628,7 @@ suspend fun readLampAlarmModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 52u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampAlarmModeAttribute( @@ -1769,123 +1636,116 @@ suspend fun readLampAlarmModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 52u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampalarmmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lampalarmmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribute {val ATTRIBUTE_ID: UInt = 53u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribute { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampburnhourstrippoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampburnhourstrippoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LampBurnHoursTripPointAttribute(decodedValue) } suspend fun writeLampBurnHoursTripPointAttribute( value: UInt, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 53u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1907,7 +1767,7 @@ suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribu throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampBurnHoursTripPointAttribute( @@ -1915,101 +1775,97 @@ suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LampBurnHoursTripPointAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LampBurnHoursTripPointAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampburnhourstrippoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lampburnhourstrippoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LampBurnHoursTripPointAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LampBurnHoursTripPointAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LampBurnHoursTripPointAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2019,45 +1875,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2065,49 +1926,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2117,45 +1972,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2163,49 +2023,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2215,45 +2069,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2261,49 +2118,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2313,45 +2164,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2359,44 +2213,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2405,35 +2252,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2445,44 +2294,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2491,34 +2333,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2531,7 +2377,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt index 01b8f509d4f7af..baddce34338c61 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt @@ -17,110 +17,84 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BarrierControlCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class BarrierControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun barrierControlGoToPercent(percentOpen: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun barrierControlGoToPercent(percentOpen: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_PERCENT_OPEN_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_PERCENT_OPEN_REQ), percentOpen) + tlvWriter.put(ContextSpecificTag(TAG_PERCENT_OPEN_REQ), percentOpen) tlvWriter.endStructure() val request: InvokeRequest = @@ -138,7 +112,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -151,42 +125,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readBarrierMovingStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierMovingStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriermovingstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriermovingstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -195,34 +162,38 @@ suspend fun readBarrierMovingStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriermovingstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriermovingstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -235,44 +206,37 @@ suspend fun readBarrierMovingStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierSafetyStatusAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierSafetyStatusAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriersafetystatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriersafetystatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -281,34 +245,38 @@ suspend fun readBarrierSafetyStatusAttribute(): UShort {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriersafetystatus attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriersafetystatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -321,44 +289,37 @@ suspend fun readBarrierSafetyStatusAttribute(): UShort {val ATTRIBUTE_ID: UInt = emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierCapabilitiesAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierCapabilitiesAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercapabilities attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercapabilities attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -367,34 +328,38 @@ suspend fun readBarrierCapabilitiesAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercapabilities attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercapabilities attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -407,71 +372,61 @@ suspend fun readBarrierCapabilitiesAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierOpenEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrieropenevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barrieropenevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeBarrierOpenEventsAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierOpenEventsAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -493,7 +448,7 @@ suspend fun readBarrierOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierOpenEventsAttribute( @@ -501,118 +456,110 @@ suspend fun readBarrierOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrieropenevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barrieropenevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierCloseEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercloseevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercloseevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeBarrierCloseEventsAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierCloseEventsAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -634,7 +581,7 @@ suspend fun readBarrierCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierCloseEventsAttribute( @@ -642,118 +589,113 @@ suspend fun readBarrierCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercloseevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercloseevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierCommandOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierCommandOpenEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercommandopenevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercommandopenevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeBarrierCommandOpenEventsAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -775,7 +717,7 @@ suspend fun readBarrierCommandOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierCommandOpenEventsAttribute( @@ -783,118 +725,113 @@ suspend fun readBarrierCommandOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercommandopenevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercommandopenevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierCommandCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierCommandCloseEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercommandcloseevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercommandcloseevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeBarrierCommandCloseEventsAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -916,7 +853,7 @@ suspend fun readBarrierCommandCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierCommandCloseEventsAttribute( @@ -924,118 +861,110 @@ suspend fun readBarrierCommandCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercommandcloseevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercommandcloseevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierOpenPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrieropenperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barrieropenperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeBarrierOpenPeriodAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierOpenPeriodAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1057,7 +986,7 @@ suspend fun readBarrierOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierOpenPeriodAttribute( @@ -1065,118 +994,110 @@ suspend fun readBarrierOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrieropenperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barrieropenperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierClosePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierClosePeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercloseperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercloseperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeBarrierClosePeriodAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierClosePeriodAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1198,7 +1119,7 @@ suspend fun readBarrierClosePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierClosePeriodAttribute( @@ -1206,91 +1127,86 @@ suspend fun readBarrierClosePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercloseperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercloseperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierPositionAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrierposition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barrierposition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1299,34 +1215,38 @@ suspend fun readBarrierPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrierposition attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barrierposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1339,49 +1259,43 @@ suspend fun readBarrierPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1391,45 +1305,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1437,49 +1356,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1489,45 +1402,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1535,49 +1453,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1587,45 +1499,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1633,49 +1548,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1685,45 +1594,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1731,44 +1643,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1777,35 +1682,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1817,44 +1724,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1863,34 +1763,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1903,7 +1807,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt index 02d2f9bea9084e..0a669f0fddd221 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt @@ -17,132 +17,103 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationCluster(private val controller: MatterController, private val endpointId: UShort) {class CapabilityMinimaAttribute( - val value: BasicInformationClusterCapabilityMinimaStruct - ) +class BasicInformationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class CapabilityMinimaAttribute(val value: BasicInformationClusterCapabilityMinimaStruct) sealed class CapabilityMinimaAttributeSubscriptionState { - data class Success( - val value: BasicInformationClusterCapabilityMinimaStruct - ) : CapabilityMinimaAttributeSubscriptionState() - + data class Success(val value: BasicInformationClusterCapabilityMinimaStruct) : + CapabilityMinimaAttributeSubscriptionState() + data class Error(val exception: Exception) : CapabilityMinimaAttributeSubscriptionState() - object SubscriptionEstablished : CapabilityMinimaAttributeSubscriptionState() - } -class ProductAppearanceAttribute( - val value: BasicInformationClusterProductAppearanceStruct? - ) + object SubscriptionEstablished : CapabilityMinimaAttributeSubscriptionState() + } + + class ProductAppearanceAttribute(val value: BasicInformationClusterProductAppearanceStruct?) sealed class ProductAppearanceAttributeSubscriptionState { - data class Success( - val value: BasicInformationClusterProductAppearanceStruct? - ) : ProductAppearanceAttributeSubscriptionState() - + data class Success(val value: BasicInformationClusterProductAppearanceStruct?) : + ProductAppearanceAttributeSubscriptionState() + data class Error(val exception: Exception) : ProductAppearanceAttributeSubscriptionState() - object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun mfgSpecificPing(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,42 +126,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readDataModelRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDataModelRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Datamodelrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Datamodelrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -199,34 +163,38 @@ suspend fun readDataModelRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Datamodelrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Datamodelrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -239,44 +207,37 @@ suspend fun readDataModelRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorNameAttribute(): String {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVendorNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -285,35 +246,37 @@ suspend fun readVendorNameAttribute(): String {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -325,44 +288,37 @@ suspend fun readVendorNameAttribute(): String {val ATTRIBUTE_ID: UInt = 1u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVendorIDAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -371,35 +327,37 @@ suspend fun readVendorIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -411,44 +369,37 @@ suspend fun readVendorIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductNameAttribute(): String {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -457,35 +408,37 @@ suspend fun readProductNameAttribute(): String {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -497,44 +450,37 @@ suspend fun readProductNameAttribute(): String {val ATTRIBUTE_ID: UInt = 3u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductIDAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -543,35 +489,37 @@ suspend fun readProductIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -583,67 +531,56 @@ suspend fun readProductIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNodeLabelAttribute(): String {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNodeLabelAttribute(): String { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nodelabel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nodelabel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeNodeLabelAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -665,7 +602,7 @@ suspend fun readNodeLabelAttribute(): String {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNodeLabelAttribute( @@ -673,35 +610,37 @@ suspend fun readNodeLabelAttribute(): String {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nodelabel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nodelabel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -713,67 +652,56 @@ suspend fun readNodeLabelAttribute(): String {val ATTRIBUTE_ID: UInt = 5u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocationAttribute(): String {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocationAttribute(): String { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Location attribute not found in response" - } + } + + requireNotNull(attributeData) { "Location attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeLocationAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLocationAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -795,7 +723,7 @@ suspend fun readLocationAttribute(): String {val ATTRIBUTE_ID: UInt = 6u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocationAttribute( @@ -803,35 +731,37 @@ suspend fun readLocationAttribute(): String {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Location attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Location attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -843,44 +773,37 @@ suspend fun readLocationAttribute(): String {val ATTRIBUTE_ID: UInt = 6u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHardwareVersionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwareversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -889,34 +812,38 @@ suspend fun readHardwareVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -929,44 +856,37 @@ suspend fun readHardwareVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 7u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHardwareVersionStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwareversionstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -975,34 +895,38 @@ suspend fun readHardwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1015,44 +939,37 @@ suspend fun readHardwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoftwareVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSoftwareVersionAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Softwareversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1061,34 +978,38 @@ suspend fun readSoftwareVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Softwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1101,44 +1022,37 @@ suspend fun readSoftwareVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 9u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoftwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSoftwareVersionStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Softwareversionstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -1147,34 +1061,38 @@ suspend fun readSoftwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Softwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1187,47 +1105,41 @@ suspend fun readSoftwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readManufacturingDateAttribute(): String? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Manufacturingdate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1237,94 +1149,90 @@ suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Manufacturingdate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPartNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1334,94 +1242,88 @@ suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Partnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductURLAttribute(): String? { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Producturl attribute not found in response" - } + } + + requireNotNull(attributeData) { "Producturl attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1431,94 +1333,88 @@ suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Producturl attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Producturl attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductLabelAttribute(): String? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productlabel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productlabel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1528,94 +1424,88 @@ suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productlabel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productlabel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSerialNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serialnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Serialnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1625,118 +1515,111 @@ suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serialnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Serialnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocalConfigDisabledAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocalConfigDisabledAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localconfigdisabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localconfigdisabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeLocalConfigDisabledAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1758,7 +1641,7 @@ suspend fun readLocalConfigDisabledAttribute(): Boolean? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocalConfigDisabledAttribute( @@ -1766,94 +1649,90 @@ suspend fun readLocalConfigDisabledAttribute(): Boolean? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localconfigdisabled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Localconfigdisabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReachableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReachableAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reachable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reachable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1863,94 +1742,88 @@ suspend fun readReachableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reachable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reachable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUniqueIDAttribute(): String? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uniqueid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uniqueid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1960,90 +1833,84 @@ suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uniqueid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uniqueid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Capabilityminima attribute not found in response" - } + } + + requireNotNull(attributeData) { "Capabilityminima attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterCapabilityMinimaStruct = BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: BasicInformationClusterCapabilityMinimaStruct = + BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) return CapabilityMinimaAttribute(decodedValue) } @@ -2053,39 +1920,44 @@ suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CapabilityMinimaAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CapabilityMinimaAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Capabilityminima attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Capabilityminima attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterCapabilityMinimaStruct = BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: BasicInformationClusterCapabilityMinimaStruct = + BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) emit(CapabilityMinimaAttributeSubscriptionState.Success(decodedValue)) } @@ -2093,47 +1965,41 @@ suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute {val ATTR emit(CapabilityMinimaAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productappearance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productappearance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { - BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - + val decodedValue: BasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } return ProductAppearanceAttribute(decodedValue) } @@ -2143,91 +2009,86 @@ suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ProductAppearanceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ProductAppearanceAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productappearance attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Productappearance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { - BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } + val decodedValue: BasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } - decodedValue?.let { - emit(ProductAppearanceAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ProductAppearanceAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ProductAppearanceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpecificationVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSpecificationVersionAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Specificationversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Specificationversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2236,34 +2097,38 @@ suspend fun readSpecificationVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Specificationversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Specificationversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2276,44 +2141,37 @@ suspend fun readSpecificationVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxPathsPerInvokeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxPathsPerInvokeAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpathsperinvoke attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxpathsperinvoke attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2322,34 +2180,38 @@ suspend fun readMaxPathsPerInvokeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpathsperinvoke attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxpathsperinvoke attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2362,49 +2224,43 @@ suspend fun readMaxPathsPerInvokeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2414,45 +2270,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2460,49 +2321,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2512,45 +2367,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2558,49 +2418,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2610,45 +2464,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2656,49 +2513,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2708,45 +2559,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2754,44 +2608,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2800,35 +2647,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2840,44 +2689,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2886,34 +2728,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2926,7 +2772,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt index 6573eb5ba275c1..89769881291daf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt @@ -17,163 +17,126 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BinaryInputBasicCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class BinaryInputBasicCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readActiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readActiveTextAttribute(): String? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetext attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activetext attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeActiveTextAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeActiveTextAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -195,7 +158,7 @@ suspend fun readActiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeActiveTextAttribute( @@ -203,118 +166,108 @@ suspend fun readActiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetext attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activetext attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 28u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDescriptionAttribute(): String? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in response" - } + } + + requireNotNull(attributeData) { "Description attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeDescriptionAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeDescriptionAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 28u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -336,7 +289,7 @@ suspend fun readDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 28u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDescriptionAttribute( @@ -344,118 +297,108 @@ suspend fun readDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 28u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Description attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInactiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 46u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInactiveTextAttribute(): String? { + val ATTRIBUTE_ID: UInt = 46u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inactivetext attribute not found in response" - } + } + + requireNotNull(attributeData) { "Inactivetext attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeInactiveTextAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeInactiveTextAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 46u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -477,7 +420,7 @@ suspend fun readInactiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 46u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInactiveTextAttribute( @@ -485,114 +428,103 @@ suspend fun readInactiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 46u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 46u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inactivetext attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Inactivetext attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOutOfServiceAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 81u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOutOfServiceAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 81u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outofservice attribute not found in response" - } + } + + requireNotNull(attributeData) { "Outofservice attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeOutOfServiceAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeOutOfServiceAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 81u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -614,7 +546,7 @@ suspend fun readOutOfServiceAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 81u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOutOfServiceAttribute( @@ -622,35 +554,37 @@ suspend fun readOutOfServiceAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 81u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 81u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outofservice attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Outofservice attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -662,47 +596,41 @@ suspend fun readOutOfServiceAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 81u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPolarityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 84u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPolarityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 84u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Polarity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Polarity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -712,114 +640,103 @@ suspend fun readPolarityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 84u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 84u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Polarity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Polarity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPresentValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 85u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPresentValueAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 85u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presentvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Presentvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writePresentValueAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writePresentValueAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 85u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -841,7 +758,7 @@ suspend fun readPresentValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 85u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePresentValueAttribute( @@ -849,35 +766,37 @@ suspend fun readPresentValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 85u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 85u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presentvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Presentvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -889,71 +808,61 @@ suspend fun readPresentValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 85u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReliabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 103u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readReliabilityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 103u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reliability attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reliability attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeReliabilityAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeReliabilityAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 103u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -975,7 +884,7 @@ suspend fun readReliabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 103u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeReliabilityAttribute( @@ -983,91 +892,84 @@ suspend fun readReliabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 103u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 103u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reliability attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reliability attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStatusFlagsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 111u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStatusFlagsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 111u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Statusflags attribute not found in response" - } + } + + requireNotNull(attributeData) { "Statusflags attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1076,35 +978,37 @@ suspend fun readStatusFlagsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 111u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 111u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Statusflags attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Statusflags attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1116,47 +1020,41 @@ suspend fun readStatusFlagsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 111u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApplicationTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 256u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readApplicationTypeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 256u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationtype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Applicationtype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -1166,96 +1064,92 @@ suspend fun readApplicationTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 256u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 256u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationtype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Applicationtype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1265,45 +1159,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1311,49 +1210,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1363,45 +1256,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1409,49 +1307,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1461,45 +1353,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1507,49 +1402,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1559,45 +1448,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1605,44 +1497,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1651,35 +1536,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1691,44 +1578,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1737,34 +1617,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1777,7 +1661,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt index a29864051af0d1..a5cb5193c9c37d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt @@ -17,182 +17,140 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BindingCluster(private val controller: MatterController, private val endpointId: UShort) {class BindingAttribute( - val value: List - ) +class BindingCluster(private val controller: MatterController, private val endpointId: UShort) { + class BindingAttribute(val value: List) sealed class BindingAttributeSubscriptionState { - data class Success( - val value: List - ) : BindingAttributeSubscriptionState() - + data class Success(val value: List) : + BindingAttributeSubscriptionState() + data class Error(val exception: Exception) : BindingAttributeSubscriptionState() - object SubscriptionEstablished : BindingAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : BindingAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readBindingAttribute(): BindingAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readBindingAttribute(): BindingAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Binding attribute not found in response" - } + } + + requireNotNull(attributeData) { "Binding attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return BindingAttribute(decodedValue) } suspend fun writeBindingAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -214,7 +172,7 @@ suspend fun readBindingAttribute(): BindingAttribute {val ATTRIBUTE_ID: UInt = 0 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBindingAttribute( @@ -222,45 +180,48 @@ suspend fun readBindingAttribute(): BindingAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BindingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BindingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Binding attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Binding attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(BindingAttributeSubscriptionState.Success(decodedValue)) } @@ -268,49 +229,43 @@ suspend fun readBindingAttribute(): BindingAttribute {val ATTRIBUTE_ID: UInt = 0 emit(BindingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -320,45 +275,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -366,49 +326,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -418,45 +372,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -464,49 +423,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -516,45 +469,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -562,49 +518,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -614,45 +564,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -660,44 +613,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -706,35 +652,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -746,44 +694,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -792,34 +733,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -832,7 +777,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt index 0c44c4bb081d4a..7530f3afc9c7cb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt @@ -17,136 +17,96 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class BooleanStateCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class BooleanStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readStateValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readStateValueAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Statevalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Statevalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -155,35 +115,37 @@ suspend fun readStateValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Statevalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Statevalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,49 +157,43 @@ suspend fun readStateValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -247,45 +203,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -293,49 +254,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -345,45 +300,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -391,49 +351,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -443,45 +397,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -489,49 +446,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -541,45 +492,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -587,44 +541,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -633,35 +580,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -673,44 +622,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -719,34 +661,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -759,7 +705,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt index a92edf5556e383..3cbd118dac1c2e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt @@ -17,110 +17,84 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class BooleanStateConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun suppressAlarm(alarmsToSuppress: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun suppressAlarm(alarmsToSuppress: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ALARMS_TO_SUPPRESS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_SUPPRESS_REQ), alarmsToSuppress) + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_SUPPRESS_REQ), alarmsToSuppress) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,15 +108,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableDisableAlarm(alarmsToEnableDisable: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enableDisableAlarm( + alarmsToEnableDisable: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ALARMS_TO_ENABLE_DISABLE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_ENABLE_DISABLE_REQ), alarmsToEnableDisable) + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_ENABLE_DISABLE_REQ), alarmsToEnableDisable) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,69 +131,62 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCurrentSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentSensitivityLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentsensitivitylevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentsensitivitylevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeCurrentSensitivityLevelAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -239,7 +208,7 @@ suspend fun readCurrentSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCurrentSensitivityLevelAttribute( @@ -247,94 +216,90 @@ suspend fun readCurrentSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentsensitivitylevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentsensitivitylevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedSensitivityLevelsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedSensitivityLevelsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedsensitivitylevels attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedsensitivitylevels attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -344,94 +309,90 @@ suspend fun readSupportedSensitivityLevelsAttribute(): UByte? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedsensitivitylevels attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedsensitivitylevels attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultSensitivityLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultsensitivitylevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultsensitivitylevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -441,94 +402,90 @@ suspend fun readDefaultSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultsensitivitylevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultsensitivitylevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAlarmsActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAlarmsActiveAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmsactive attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alarmsactive attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -538,94 +495,88 @@ suspend fun readAlarmsActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmsactive attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Alarmsactive attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAlarmsSuppressedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAlarmsSuppressedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmssuppressed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alarmssuppressed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -635,94 +586,90 @@ suspend fun readAlarmsSuppressedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmssuppressed attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alarmssuppressed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAlarmsEnabledAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAlarmsEnabledAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmsenabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alarmsenabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -732,94 +679,88 @@ suspend fun readAlarmsEnabledAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmsenabled attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Alarmsenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAlarmsSupportedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAlarmsSupportedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmssupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alarmssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -829,94 +770,90 @@ suspend fun readAlarmsSupportedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alarmssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSensorFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSensorFaultAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sensorfault attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sensorfault attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -926,96 +863,90 @@ suspend fun readSensorFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sensorfault attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Sensorfault attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1025,45 +956,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1071,49 +1007,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1123,45 +1053,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1169,49 +1104,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1221,45 +1150,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1267,49 +1199,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1319,45 +1245,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1365,44 +1294,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1411,35 +1333,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1451,44 +1375,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1497,34 +1414,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1537,7 +1458,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt index 463def619140dc..e867b53a3b8e24 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt @@ -17,152 +17,118 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationCluster(private val controller: MatterController, private val endpointId: UShort) {class ProductAppearanceAttribute( +class BridgedDeviceBasicInformationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ProductAppearanceAttribute( val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct? ) sealed class ProductAppearanceAttributeSubscriptionState { - data class Success( - val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct? - ) : ProductAppearanceAttributeSubscriptionState() - + data class Success(val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct?) : + ProductAppearanceAttributeSubscriptionState() + data class Error(val exception: Exception) : ProductAppearanceAttributeSubscriptionState() - object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readVendorNameAttribute(): String? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -172,94 +138,88 @@ suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readVendorIDAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -269,94 +229,88 @@ suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductNameAttribute(): String? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -366,118 +320,108 @@ suspend fun readProductNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNodeLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNodeLabelAttribute(): String? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nodelabel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nodelabel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeNodeLabelAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +443,7 @@ suspend fun readNodeLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNodeLabelAttribute( @@ -507,94 +451,88 @@ suspend fun readNodeLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nodelabel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nodelabel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readHardwareVersionAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwareversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -604,94 +542,90 @@ suspend fun readHardwareVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readHardwareVersionStringAttribute(): String? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwareversionstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -701,94 +635,90 @@ suspend fun readHardwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoftwareVersionAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSoftwareVersionAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Softwareversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -798,94 +728,90 @@ suspend fun readSoftwareVersionAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Softwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoftwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSoftwareVersionStringAttribute(): String? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Softwareversionstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -895,94 +821,90 @@ suspend fun readSoftwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Softwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readManufacturingDateAttribute(): String? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Manufacturingdate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -992,94 +914,90 @@ suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Manufacturingdate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPartNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1089,94 +1007,88 @@ suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Partnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductURLAttribute(): String? { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Producturl attribute not found in response" - } + } + + requireNotNull(attributeData) { "Producturl attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1186,94 +1098,88 @@ suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Producturl attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Producturl attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductLabelAttribute(): String? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productlabel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productlabel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1283,94 +1189,88 @@ suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productlabel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productlabel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSerialNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serialnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Serialnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1380,91 +1280,84 @@ suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serialnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Serialnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReachableAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 17u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readReachableAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reachable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reachable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -1473,35 +1366,37 @@ suspend fun readReachableAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reachable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reachable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1513,47 +1408,41 @@ suspend fun readReachableAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 17u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUniqueIDAttribute(): String? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uniqueid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uniqueid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1563,94 +1452,88 @@ suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uniqueid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uniqueid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val ATTRIBUTE_ID: UInt = 20u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productappearance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productappearance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { - BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - + val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } return ProductAppearanceAttribute(decodedValue) } @@ -1660,96 +1543,95 @@ suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ProductAppearanceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ProductAppearanceAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productappearance attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Productappearance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { - BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - - decodedValue?.let { - emit(ProductAppearanceAttributeSubscriptionState.Success(it)) - } - + val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + + decodedValue?.let { emit(ProductAppearanceAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ProductAppearanceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1759,45 +1641,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1805,49 +1692,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1857,45 +1738,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1903,49 +1789,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1955,45 +1835,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2001,49 +1884,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2053,45 +1930,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2099,44 +1979,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2145,35 +2018,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2185,44 +2060,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2231,34 +2099,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2271,7 +2143,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt index 32fbbb01553d32..d2f974c4550a9b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class CarbonDioxideConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class CarbonDioxideConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(CarbonDioxideConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger(CarbonDioxideConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1037u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt index c97c2f69df0087..93341731a25b70 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class CarbonMonoxideConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class CarbonMonoxideConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(CarbonMonoxideConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger(CarbonMonoxideConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1036u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt index ce6d28c380c36b..653f118fc66440 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt @@ -17,159 +17,120 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class ChannelCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeChannelResponse( - val status: UByte, - val data: String? - ) + class ChangeChannelResponse(val status: UByte, val data: String?) class ProgramGuideResponse( - val paging: ChannelClusterChannelPagingStruct, + val paging: ChannelClusterChannelPagingStruct, val programList: List ) -class ChannelListAttribute( - val value: List? - ) + + class ChannelListAttribute(val value: List?) sealed class ChannelListAttributeSubscriptionState { - data class Success( - val value: List? - ) : ChannelListAttributeSubscriptionState() - + data class Success(val value: List?) : + ChannelListAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelListAttributeSubscriptionState() - object SubscriptionEstablished : ChannelListAttributeSubscriptionState() - } -class LineupAttribute( - val value: ChannelClusterLineupInfoStruct? - ) + object SubscriptionEstablished : ChannelListAttributeSubscriptionState() + } + + class LineupAttribute(val value: ChannelClusterLineupInfoStruct?) sealed class LineupAttributeSubscriptionState { - data class Success( - val value: ChannelClusterLineupInfoStruct? - ) : LineupAttributeSubscriptionState() - + data class Success(val value: ChannelClusterLineupInfoStruct?) : + LineupAttributeSubscriptionState() + data class Error(val exception: Exception) : LineupAttributeSubscriptionState() - object SubscriptionEstablished : LineupAttributeSubscriptionState() - } -class CurrentChannelAttribute( - val value: ChannelClusterChannelInfoStruct? - ) + object SubscriptionEstablished : LineupAttributeSubscriptionState() + } + + class CurrentChannelAttribute(val value: ChannelClusterChannelInfoStruct?) sealed class CurrentChannelAttributeSubscriptionState { - data class Success( - val value: ChannelClusterChannelInfoStruct? - ) : CurrentChannelAttributeSubscriptionState() - + data class Success(val value: ChannelClusterChannelInfoStruct?) : + CurrentChannelAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentChannelAttributeSubscriptionState() - object SubscriptionEstablished : CurrentChannelAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : CurrentChannelAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeChannel(match: String - ,timedInvokeTimeout: Duration? = null): ChangeChannelResponse { + suspend fun changeChannel( + match: String, + timedInvokeTimeout: Duration? = null + ): ChangeChannelResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_MATCH_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_MATCH_REQ), match) + tlvWriter.put(ContextSpecificTag(TAG_MATCH_REQ), match) tlvWriter.endStructure() val request: InvokeRequest = @@ -186,55 +147,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeChannelResponse( - status_decoded, - data_decoded - ) + return ChangeChannelResponse(status_decoded, data_decoded) } - suspend fun changeChannelByNumber(majorNumber: UShort - ,minorNumber: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun changeChannelByNumber( + majorNumber: UShort, + minorNumber: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -244,7 +198,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MAJOR_NUMBER_REQ), majorNumber) val TAG_MINOR_NUMBER_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_MINOR_NUMBER_REQ), minorNumber) + tlvWriter.put(ContextSpecificTag(TAG_MINOR_NUMBER_REQ), minorNumber) tlvWriter.endStructure() val request: InvokeRequest = @@ -258,15 +212,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun skipChannel(count: Short - ,timedInvokeTimeout: Duration? = null) { + suspend fun skipChannel(count: Short, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_COUNT_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) + tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) tlvWriter.endStructure() val request: InvokeRequest = @@ -280,28 +233,26 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getProgramGuide(startTime: UInt? - ,endTime: UInt? - ,channelList: List? - ,pageToken: ChannelClusterPageTokenStruct? - ,recordingFlag: UInt? - ,externalIDList: List? - ,data: ByteArray? - ,timedInvokeTimeout: Duration? = null): ProgramGuideResponse { + suspend fun getProgramGuide( + startTime: UInt?, + endTime: UInt?, + channelList: List?, + pageToken: ChannelClusterPageTokenStruct?, + recordingFlag: UInt?, + externalIDList: List?, + data: ByteArray?, + timedInvokeTimeout: Duration? = null + ): ProgramGuideResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_START_TIME_REQ: Int = 0 - startTime?.let { - tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) - } + startTime?.let { tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) } val TAG_END_TIME_REQ: Int = 1 - endTime?.let { - tlvWriter.put(ContextSpecificTag(TAG_END_TIME_REQ), endTime) - } + endTime?.let { tlvWriter.put(ContextSpecificTag(TAG_END_TIME_REQ), endTime) } val TAG_CHANNEL_LIST_REQ: Int = 2 channelList?.let { @@ -313,14 +264,10 @@ class AttributeListAttribute( } val TAG_PAGE_TOKEN_REQ: Int = 3 - pageToken?.let { - pageToken.toTlv(ContextSpecificTag(TAG_PAGE_TOKEN_REQ), tlvWriter) - } + pageToken?.let { pageToken.toTlv(ContextSpecificTag(TAG_PAGE_TOKEN_REQ), tlvWriter) } val TAG_RECORDING_FLAG_REQ: Int = 4 - recordingFlag?.let { - tlvWriter.put(ContextSpecificTag(TAG_RECORDING_FLAG_REQ), recordingFlag) - } + recordingFlag?.let { tlvWriter.put(ContextSpecificTag(TAG_RECORDING_FLAG_REQ), recordingFlag) } val TAG_EXTERNAL_I_D_LIST_REQ: Int = 5 externalIDList?.let { @@ -332,9 +279,7 @@ class AttributeListAttribute( } val TAG_DATA_REQ: Int = 6 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } tlvWriter.endStructure() val request: InvokeRequest = @@ -351,56 +296,51 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_PAGING: Int = 0 var paging_decoded: ChannelClusterChannelPagingStruct? = null - + val TAG_PROGRAM_LIST: Int = 1 var programList_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_PAGING)) {paging_decoded = ChannelClusterChannelPagingStruct.fromTlv(tag, tlvReader)} - - if (tag == ContextSpecificTag(TAG_PROGRAM_LIST)) {programList_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramStruct.fromTlv(AnonymousTag, tlvReader)) + if (tag == ContextSpecificTag(TAG_PAGING)) { + paging_decoded = ChannelClusterChannelPagingStruct.fromTlv(tag, tlvReader) } - tlvReader.exitContainer() - }} - - else { + if (tag == ContextSpecificTag(TAG_PROGRAM_LIST)) { + programList_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (paging_decoded == null) { - throw IllegalStateException("paging not found in TLV") + throw IllegalStateException("paging not found in TLV") } - - + if (programList_decoded == null) { - throw IllegalStateException("programList not found in TLV") + throw IllegalStateException("programList not found in TLV") } - tlvReader.exitContainer() - return ProgramGuideResponse( - paging_decoded, - programList_decoded - ) + return ProgramGuideResponse(paging_decoded, programList_decoded) } - suspend fun recordProgram(programIdentifier: String - ,shouldRecordSeries: Boolean - ,externalIDList: List - ,data: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun recordProgram( + programIdentifier: String, + shouldRecordSeries: Boolean, + externalIDList: List, + data: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -414,13 +354,13 @@ class AttributeListAttribute( val TAG_EXTERNAL_I_D_LIST_REQ: Int = 2 tlvWriter.startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST_REQ)) - for (item in externalIDList.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in externalIDList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_DATA_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) tlvWriter.endStructure() val request: InvokeRequest = @@ -434,11 +374,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun cancelRecordProgram(programIdentifier: String - ,shouldRecordSeries: Boolean - ,externalIDList: List - ,data: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun cancelRecordProgram( + programIdentifier: String, + shouldRecordSeries: Boolean, + externalIDList: List, + data: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -452,13 +394,13 @@ class AttributeListAttribute( val TAG_EXTERNAL_I_D_LIST_REQ: Int = 2 tlvWriter.startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST_REQ)) - for (item in externalIDList.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in externalIDList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_DATA_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) tlvWriter.endStructure() val request: InvokeRequest = @@ -471,51 +413,45 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readChannelListAttribute(): ChannelListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readChannelListAttribute(): ChannelListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channellist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Channellist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ChannelListAttribute(decodedValue) } @@ -525,105 +461,99 @@ suspend fun readChannelListAttribute(): ChannelListAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChannelListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChannelListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channellist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Channellist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ChannelListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ChannelListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChannelListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLineupAttribute(): LineupAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLineupAttribute(): LineupAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lineup attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lineup attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterLineupInfoStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ChannelClusterLineupInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LineupAttribute(decodedValue) } @@ -633,104 +563,98 @@ suspend fun readLineupAttribute(): LineupAttribute {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LineupAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LineupAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lineup attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lineup attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterLineupInfoStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LineupAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ChannelClusterLineupInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LineupAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LineupAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentchannel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentchannel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterChannelInfoStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ChannelClusterChannelInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentChannelAttribute(decodedValue) } @@ -740,101 +664,97 @@ suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentChannelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentChannelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentchannel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentchannel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterChannelInfoStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentChannelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ChannelClusterChannelInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentChannelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentChannelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -844,45 +764,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -890,49 +815,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -942,45 +861,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -988,49 +912,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1040,45 +958,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1086,49 +1007,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1138,45 +1053,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1184,44 +1102,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1230,35 +1141,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1270,44 +1183,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1316,34 +1222,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1356,7 +1266,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt index 22dd04f551f5f8..29633f95e9ab20 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt @@ -17,250 +17,197 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ColorControlCluster(private val controller: MatterController, private val endpointId: UShort) {class NumberOfPrimariesAttribute( - val value: UByte? - ) +class ColorControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class NumberOfPrimariesAttribute(val value: UByte?) sealed class NumberOfPrimariesAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NumberOfPrimariesAttributeSubscriptionState() - + data class Success(val value: UByte?) : NumberOfPrimariesAttributeSubscriptionState() + data class Error(val exception: Exception) : NumberOfPrimariesAttributeSubscriptionState() - object SubscriptionEstablished : NumberOfPrimariesAttributeSubscriptionState() - } -class Primary1IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NumberOfPrimariesAttributeSubscriptionState() + } + + class Primary1IntensityAttribute(val value: UByte?) sealed class Primary1IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary1IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary1IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary1IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary1IntensityAttributeSubscriptionState() - } -class Primary2IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary1IntensityAttributeSubscriptionState() + } + + class Primary2IntensityAttribute(val value: UByte?) sealed class Primary2IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary2IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary2IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary2IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary2IntensityAttributeSubscriptionState() - } -class Primary3IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary2IntensityAttributeSubscriptionState() + } + + class Primary3IntensityAttribute(val value: UByte?) sealed class Primary3IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary3IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary3IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary3IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary3IntensityAttributeSubscriptionState() - } -class Primary4IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary3IntensityAttributeSubscriptionState() + } + + class Primary4IntensityAttribute(val value: UByte?) sealed class Primary4IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary4IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary4IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary4IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary4IntensityAttributeSubscriptionState() - } -class Primary5IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary4IntensityAttributeSubscriptionState() + } + + class Primary5IntensityAttribute(val value: UByte?) sealed class Primary5IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary5IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary5IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary5IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary5IntensityAttributeSubscriptionState() - } -class Primary6IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary5IntensityAttributeSubscriptionState() + } + + class Primary6IntensityAttribute(val value: UByte?) sealed class Primary6IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary6IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary6IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary6IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary6IntensityAttributeSubscriptionState() - } -class ColorPointRIntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary6IntensityAttributeSubscriptionState() + } + + class ColorPointRIntensityAttribute(val value: UByte?) sealed class ColorPointRIntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : ColorPointRIntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : ColorPointRIntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : ColorPointRIntensityAttributeSubscriptionState() - object SubscriptionEstablished : ColorPointRIntensityAttributeSubscriptionState() - } -class ColorPointGIntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : ColorPointRIntensityAttributeSubscriptionState() + } + + class ColorPointGIntensityAttribute(val value: UByte?) sealed class ColorPointGIntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : ColorPointGIntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : ColorPointGIntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : ColorPointGIntensityAttributeSubscriptionState() - object SubscriptionEstablished : ColorPointGIntensityAttributeSubscriptionState() - } -class ColorPointBIntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : ColorPointGIntensityAttributeSubscriptionState() + } + + class ColorPointBIntensityAttribute(val value: UByte?) sealed class ColorPointBIntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : ColorPointBIntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : ColorPointBIntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : ColorPointBIntensityAttributeSubscriptionState() - object SubscriptionEstablished : ColorPointBIntensityAttributeSubscriptionState() - } -class StartUpColorTemperatureMiredsAttribute( - val value: UShort? - ) + object SubscriptionEstablished : ColorPointBIntensityAttributeSubscriptionState() + } + + class StartUpColorTemperatureMiredsAttribute(val value: UShort?) sealed class StartUpColorTemperatureMiredsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : StartUpColorTemperatureMiredsAttributeSubscriptionState() - - data class Error(val exception: Exception) : StartUpColorTemperatureMiredsAttributeSubscriptionState() - - object SubscriptionEstablished : StartUpColorTemperatureMiredsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: UShort?) : + StartUpColorTemperatureMiredsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + StartUpColorTemperatureMiredsAttributeSubscriptionState() + + object SubscriptionEstablished : StartUpColorTemperatureMiredsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun moveToHue(hue: UByte - ,direction: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToHue( + hue: UByte, + direction: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -279,7 +226,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -293,11 +240,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveHue(moveMode: UByte - ,rate: UByte - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveHue( + moveMode: UByte, + rate: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -313,7 +262,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -327,12 +276,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepHue(stepMode: UByte - ,stepSize: UByte - ,transitionTime: UByte - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepHue( + stepMode: UByte, + stepSize: UByte, + transitionTime: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -351,7 +302,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -365,11 +316,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToSaturation(saturation: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToSaturation( + saturation: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -385,7 +338,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -399,11 +352,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveSaturation(moveMode: UByte - ,rate: UByte - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveSaturation( + moveMode: UByte, + rate: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -419,7 +374,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -433,12 +388,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepSaturation(stepMode: UByte - ,stepSize: UByte - ,transitionTime: UByte - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepSaturation( + stepMode: UByte, + stepSize: UByte, + transitionTime: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -457,7 +414,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -471,12 +428,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToHueAndSaturation(hue: UByte - ,saturation: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToHueAndSaturation( + hue: UByte, + saturation: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -495,7 +454,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -509,12 +468,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToColor(colorX: UShort - ,colorY: UShort - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToColor( + colorX: UShort, + colorY: UShort, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -533,7 +494,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -547,11 +508,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveColor(rateX: Short - ,rateY: Short - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveColor( + rateX: Short, + rateY: Short, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 8u val tlvWriter = TlvWriter() @@ -567,7 +530,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -581,12 +544,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepColor(stepX: Short - ,stepY: Short - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepColor( + stepX: Short, + stepY: Short, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -605,7 +570,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -619,11 +584,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToColorTemperature(colorTemperatureMireds: UShort - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToColorTemperature( + colorTemperatureMireds: UShort, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 10u val tlvWriter = TlvWriter() @@ -639,7 +606,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -653,12 +620,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedMoveToHue(enhancedHue: UShort - ,direction: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enhancedMoveToHue( + enhancedHue: UShort, + direction: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -677,7 +646,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -691,11 +660,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedMoveHue(moveMode: UByte - ,rate: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enhancedMoveHue( + moveMode: UByte, + rate: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 65u val tlvWriter = TlvWriter() @@ -711,7 +682,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -725,12 +696,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedStepHue(stepMode: UByte - ,stepSize: UShort - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enhancedStepHue( + stepMode: UByte, + stepSize: UShort, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 66u val tlvWriter = TlvWriter() @@ -749,7 +722,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -763,12 +736,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedMoveToHueAndSaturation(enhancedHue: UShort - ,saturation: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enhancedMoveToHueAndSaturation( + enhancedHue: UShort, + saturation: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 67u val tlvWriter = TlvWriter() @@ -787,7 +762,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -801,14 +776,16 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun colorLoopSet(updateFlags: UByte - ,action: UByte - ,direction: UByte - ,time: UShort - ,startHue: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun colorLoopSet( + updateFlags: UByte, + action: UByte, + direction: UByte, + time: UShort, + startHue: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 68u val tlvWriter = TlvWriter() @@ -833,7 +810,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 6 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -847,9 +824,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stopMoveStep(optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stopMoveStep( + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 71u val tlvWriter = TlvWriter() @@ -859,7 +838,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -873,13 +852,15 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveColorTemperature(moveMode: UByte - ,rate: UShort - ,colorTemperatureMinimumMireds: UShort - ,colorTemperatureMaximumMireds: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveColorTemperature( + moveMode: UByte, + rate: UShort, + colorTemperatureMinimumMireds: UShort, + colorTemperatureMaximumMireds: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 75u val tlvWriter = TlvWriter() @@ -892,16 +873,22 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) val TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), colorTemperatureMinimumMireds) + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), + colorTemperatureMinimumMireds + ) val TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), colorTemperatureMaximumMireds) + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), + colorTemperatureMaximumMireds + ) val TAG_OPTIONS_MASK_REQ: Int = 4 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 5 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -915,14 +902,16 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepColorTemperature(stepMode: UByte - ,stepSize: UShort - ,transitionTime: UShort - ,colorTemperatureMinimumMireds: UShort - ,colorTemperatureMaximumMireds: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepColorTemperature( + stepMode: UByte, + stepSize: UShort, + transitionTime: UShort, + colorTemperatureMinimumMireds: UShort, + colorTemperatureMaximumMireds: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 76u val tlvWriter = TlvWriter() @@ -938,16 +927,22 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) val TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), colorTemperatureMinimumMireds) + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), + colorTemperatureMinimumMireds + ) val TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), colorTemperatureMaximumMireds) + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), + colorTemperatureMaximumMireds + ) val TAG_OPTIONS_MASK_REQ: Int = 5 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 6 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -960,45 +955,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCurrentHueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentHueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenthue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currenthue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1008,94 +997,88 @@ suspend fun readCurrentHueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenthue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currenthue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentSaturationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentSaturationAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentsaturation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentsaturation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1105,94 +1088,90 @@ suspend fun readCurrentSaturationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentsaturation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentsaturation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRemainingTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remainingtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1202,94 +1181,88 @@ suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingtime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Remainingtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1299,94 +1272,88 @@ suspend fun readCurrentXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currenty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1396,94 +1363,88 @@ suspend fun readCurrentYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currenty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDriftCompensationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDriftCompensationAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Driftcompensation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Driftcompensation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1493,94 +1454,90 @@ suspend fun readDriftCompensationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Driftcompensation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Driftcompensation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCompensationTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCompensationTextAttribute(): String? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Compensationtext attribute not found in response" - } + } + + requireNotNull(attributeData) { "Compensationtext attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1590,94 +1547,90 @@ suspend fun readCompensationTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 6 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Compensationtext attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Compensationtext attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorTemperatureMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorTemperatureMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortemperaturemireds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colortemperaturemireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1687,91 +1640,86 @@ suspend fun readColorTemperatureMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortemperaturemireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colortemperaturemireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colormode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colormode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1780,35 +1728,37 @@ suspend fun readColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colormode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colormode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1820,67 +1770,56 @@ suspend fun readColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 8u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOptionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Options attribute not found in response" - } + } + + requireNotNull(attributeData) { "Options attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeOptionsAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOptionsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 15u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1902,7 +1841,7 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOptionsAttribute( @@ -1910,35 +1849,37 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Options attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Options attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1950,48 +1891,42 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofprimaries attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofprimaries attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NumberOfPrimariesAttribute(decodedValue) } @@ -2001,95 +1936,91 @@ suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NumberOfPrimariesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NumberOfPrimariesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofprimaries attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofprimaries attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NumberOfPrimariesAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NumberOfPrimariesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NumberOfPrimariesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary1XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary1XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary1x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2099,94 +2030,88 @@ suspend fun readPrimary1XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary1x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary1YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary1YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary1y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2196,99 +2121,93 @@ suspend fun readPrimary1YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary1y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary1intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary1IntensityAttribute(decodedValue) } @@ -2298,99 +2217,95 @@ suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary1IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary1IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary1intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary1IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary1IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary1IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary2XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary2XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary2x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2400,94 +2315,88 @@ suspend fun readPrimary2XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 21u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary2x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary2YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary2YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary2y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2497,99 +2406,93 @@ suspend fun readPrimary2YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 22u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary2y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary2intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary2IntensityAttribute(decodedValue) } @@ -2599,99 +2502,95 @@ suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary2IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary2IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary2intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary2IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary2IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary2IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary3XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary3XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary3x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2701,94 +2600,88 @@ suspend fun readPrimary3XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 25u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary3x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary3YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary3YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary3y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2798,99 +2691,93 @@ suspend fun readPrimary3YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary3y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary3intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary3IntensityAttribute(decodedValue) } @@ -2900,99 +2787,95 @@ suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary3IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary3IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary3intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary3IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary3IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary3IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary4XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary4XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary4x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3002,94 +2885,88 @@ suspend fun readPrimary4XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary4x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary4YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary4YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary4y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3099,99 +2976,93 @@ suspend fun readPrimary4YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary4y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary4intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary4IntensityAttribute(decodedValue) } @@ -3201,99 +3072,95 @@ suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary4IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary4IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary4intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary4IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary4IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary4IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary5XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary5XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary5x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3303,94 +3170,88 @@ suspend fun readPrimary5XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 36u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary5x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary5YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary5YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary5y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3400,99 +3261,93 @@ suspend fun readPrimary5YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 37u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary5y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary5intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary5IntensityAttribute(decodedValue) } @@ -3502,99 +3357,95 @@ suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary5IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary5IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary5intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary5IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary5IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary5IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary6XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 40u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary6XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary6x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3604,94 +3455,88 @@ suspend fun readPrimary6XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 40u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary6x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary6YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary6YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary6y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3701,99 +3546,93 @@ suspend fun readPrimary6YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 41u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary6y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute {val ATTRIBUTE_ID: UInt = 42u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary6intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary6IntensityAttribute(decodedValue) } @@ -3803,123 +3642,115 @@ suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary6IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary6IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary6intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary6IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary6IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary6IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWhitePointXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWhitePointXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Whitepointx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Whitepointx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWhitePointXAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeWhitePointXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3941,7 +3772,7 @@ suspend fun readWhitePointXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWhitePointXAttribute( @@ -3949,118 +3780,108 @@ suspend fun readWhitePointXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Whitepointx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Whitepointx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWhitePointYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWhitePointYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Whitepointy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Whitepointy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWhitePointYAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeWhitePointYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4082,7 +3903,7 @@ suspend fun readWhitePointYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWhitePointYAttribute( @@ -4090,118 +3911,108 @@ suspend fun readWhitePointYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Whitepointy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Whitepointy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointRXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointRXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointrx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointrx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointRXAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointRXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4223,7 +4034,7 @@ suspend fun readColorPointRXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 50u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointRXAttribute( @@ -4231,118 +4042,108 @@ suspend fun readColorPointRXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 50u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointrx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointrx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointRYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 51u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointRYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointry attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointry attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointRYAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointRYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4364,7 +4165,7 @@ suspend fun readColorPointRYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 51u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointRYAttribute( @@ -4372,123 +4173,116 @@ suspend fun readColorPointRYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 51u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointry attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointry attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute {val ATTRIBUTE_ID: UInt = 52u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointrintensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointrintensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ColorPointRIntensityAttribute(decodedValue) } suspend fun writeColorPointRIntensityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4510,7 +4304,7 @@ suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointRIntensityAttribute( @@ -4518,123 +4312,115 @@ suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ColorPointRIntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ColorPointRIntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointrintensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorpointrintensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ColorPointRIntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ColorPointRIntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ColorPointRIntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointGXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 54u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointGXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 54u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointgx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointGXAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointGXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 54u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4656,7 +4442,7 @@ suspend fun readColorPointGXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 54u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointGXAttribute( @@ -4664,118 +4450,108 @@ suspend fun readColorPointGXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 54u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 54u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointgx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointGYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 55u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointGYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 55u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointgy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointGYAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointGYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 55u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4797,7 +4573,7 @@ suspend fun readColorPointGYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 55u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointGYAttribute( @@ -4805,123 +4581,116 @@ suspend fun readColorPointGYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 55u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 55u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointgy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute {val ATTRIBUTE_ID: UInt = 56u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute { + val ATTRIBUTE_ID: UInt = 56u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgintensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointgintensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ColorPointGIntensityAttribute(decodedValue) } suspend fun writeColorPointGIntensityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 56u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4943,7 +4712,7 @@ suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointGIntensityAttribute( @@ -4951,123 +4720,115 @@ suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 56u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ColorPointGIntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ColorPointGIntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgintensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorpointgintensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ColorPointGIntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ColorPointGIntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ColorPointGIntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointBXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 58u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointBXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 58u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointbx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointbx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointBXAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointBXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 58u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5089,7 +4850,7 @@ suspend fun readColorPointBXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 58u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointBXAttribute( @@ -5097,118 +4858,108 @@ suspend fun readColorPointBXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 58u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 58u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointbx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointbx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointBYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 59u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointBYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 59u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointby attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointby attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointBYAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointBYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 59u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5230,7 +4981,7 @@ suspend fun readColorPointBYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 59u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointBYAttribute( @@ -5238,123 +4989,116 @@ suspend fun readColorPointBYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 59u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 59u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointby attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointby attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute {val ATTRIBUTE_ID: UInt = 60u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute { + val ATTRIBUTE_ID: UInt = 60u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointbintensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointbintensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ColorPointBIntensityAttribute(decodedValue) } suspend fun writeColorPointBIntensityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 60u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5376,7 +5120,7 @@ suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointBIntensityAttribute( @@ -5384,99 +5128,95 @@ suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 60u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ColorPointBIntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ColorPointBIntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointbintensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorpointbintensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ColorPointBIntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ColorPointBIntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ColorPointBIntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnhancedCurrentHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16384u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnhancedCurrentHueAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enhancedcurrenthue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enhancedcurrenthue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5486,91 +5226,86 @@ suspend fun readEnhancedCurrentHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enhancedcurrenthue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enhancedcurrenthue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnhancedColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16385u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnhancedColorModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enhancedcolormode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enhancedcolormode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -5579,34 +5314,38 @@ suspend fun readEnhancedColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16385u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enhancedcolormode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enhancedcolormode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -5619,47 +5358,41 @@ suspend fun readEnhancedColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16386u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopActiveAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopactive attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorloopactive attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -5669,94 +5402,90 @@ suspend fun readColorLoopActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 163 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16386u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopactive attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorloopactive attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16387u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopdirection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorloopdirection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -5766,94 +5495,90 @@ suspend fun readColorLoopDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16387u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopdirection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorloopdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16388u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16388u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorlooptime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorlooptime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5863,94 +5588,88 @@ suspend fun readColorLoopTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1638 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16388u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorlooptime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorlooptime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopStartEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16389u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopStartEnhancedHueAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16389u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopstartenhancedhue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorloopstartenhancedhue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5960,94 +5679,90 @@ suspend fun readColorLoopStartEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16389u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopstartenhancedhue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorloopstartenhancedhue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16390u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16390u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopstoredenhancedhue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorloopstoredenhancedhue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6057,91 +5772,86 @@ suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16390u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopstoredenhancedhue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorloopstoredenhancedhue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorCapabilitiesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 16394u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorCapabilitiesAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 16394u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorcapabilities attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorcapabilities attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -6150,34 +5860,38 @@ suspend fun readColorCapabilitiesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16394u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorcapabilities attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorcapabilities attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6190,47 +5904,41 @@ suspend fun readColorCapabilitiesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16395u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16395u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortempphysicalminmireds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colortempphysicalminmireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6240,94 +5948,90 @@ suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16395u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortempphysicalminmireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colortempphysicalminmireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16396u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16396u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortempphysicalmaxmireds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colortempphysicalmaxmireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6337,94 +6041,92 @@ suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16396u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortempphysicalmaxmireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colortempphysicalmaxmireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16397u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16397u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Couplecolortemptolevelminmireds attribute not found in response" + } + + requireNotNull(attributeData) { + "Couplecolortemptolevelminmireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6434,123 +6136,120 @@ suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort? {val ATTRIBU maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16397u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Couplecolortemptolevelminmireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Couplecolortemptolevelminmireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatureMiredsAttribute {val ATTRIBUTE_ID: UInt = 16400u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatureMiredsAttribute { + val ATTRIBUTE_ID: UInt = 16400u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupcolortemperaturemireds attribute not found in response" + } + + requireNotNull(attributeData) { + "Startupcolortemperaturemireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpColorTemperatureMiredsAttribute(decodedValue) } suspend fun writeStartUpColorTemperatureMiredsAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16400u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6572,7 +6271,7 @@ suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatur throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpColorTemperatureMiredsAttribute( @@ -6580,101 +6279,99 @@ suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatur maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16400u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpColorTemperatureMiredsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpColorTemperatureMiredsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupcolortemperaturemireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Startupcolortemperaturemireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(StartUpColorTemperatureMiredsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(StartUpColorTemperatureMiredsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -6684,45 +6381,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6730,49 +6432,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -6782,45 +6478,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6828,49 +6529,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -6880,45 +6575,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -6926,49 +6624,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -6978,45 +6670,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -7024,44 +6719,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -7070,35 +6758,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7110,44 +6800,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -7156,34 +6839,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7196,7 +6883,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt index 034e54bd0d2c5a..4c08eb6499a918 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt @@ -17,122 +17,89 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentAppObserverCluster(private val controller: MatterController, private val endpointId: UShort) { - class ContentAppMessageResponse( - val status: UByte, - val data: String?, - val encodingHint: String? - ) -class GeneratedCommandListAttribute( - val value: List - ) +class ContentAppObserverCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ContentAppMessageResponse(val status: UByte, val data: String?, val encodingHint: String?) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun contentAppMessage(data: String? - ,encodingHint: String - ,timedInvokeTimeout: Duration? = null): ContentAppMessageResponse { + suspend fun contentAppMessage( + data: String?, + encodingHint: String, + timedInvokeTimeout: Duration? = null + ): ContentAppMessageResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DATA_REQ: Int = 0 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } val TAG_ENCODING_HINT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ENCODING_HINT_REQ), encodingHint) + tlvWriter.put(ContextSpecificTag(TAG_ENCODING_HINT_REQ), encodingHint) tlvWriter.endStructure() val request: InvokeRequest = @@ -149,110 +116,94 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - + val TAG_ENCODING_HINT: Int = 2 var encodingHint_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_ENCODING_HINT)) {encodingHint_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_ENCODING_HINT)) { + encodingHint_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - tlvReader.exitContainer() - return ContentAppMessageResponse( - status_decoded, - data_decoded, - encodingHint_decoded - ) + return ContentAppMessageResponse(status_decoded, data_decoded, encodingHint_decoded) } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -262,45 +213,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -308,49 +264,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -360,45 +310,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -406,49 +361,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -458,45 +407,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -504,49 +456,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -556,45 +502,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -602,44 +551,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -648,35 +590,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -688,44 +632,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -734,34 +671,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -774,7 +715,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt index 8da8313c8caed0..327d7b9645c408 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt @@ -17,146 +17,110 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentControlCluster(private val controller: MatterController, private val endpointId: UShort) { - class ResetPINResponse( - val PINCode: String - ) -class OnDemandRatingsAttribute( - val value: List? - ) +class ContentControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ResetPINResponse(val PINCode: String) + + class OnDemandRatingsAttribute(val value: List?) sealed class OnDemandRatingsAttributeSubscriptionState { - data class Success( - val value: List? - ) : OnDemandRatingsAttributeSubscriptionState() - + data class Success(val value: List?) : + OnDemandRatingsAttributeSubscriptionState() + data class Error(val exception: Exception) : OnDemandRatingsAttributeSubscriptionState() - object SubscriptionEstablished : OnDemandRatingsAttributeSubscriptionState() - } -class ScheduledContentRatingsAttribute( - val value: List? - ) + object SubscriptionEstablished : OnDemandRatingsAttributeSubscriptionState() + } + + class ScheduledContentRatingsAttribute(val value: List?) sealed class ScheduledContentRatingsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ScheduledContentRatingsAttributeSubscriptionState() - - data class Error(val exception: Exception) : ScheduledContentRatingsAttributeSubscriptionState() - - object SubscriptionEstablished : ScheduledContentRatingsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List?) : + ScheduledContentRatingsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + ScheduledContentRatingsAttributeSubscriptionState() + + object SubscriptionEstablished : ScheduledContentRatingsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun updatePIN(oldPIN: String? - ,newPIN: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun updatePIN(oldPIN: String?, newPIN: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_OLD_P_I_N_REQ: Int = 0 - oldPIN?.let { - tlvWriter.put(ContextSpecificTag(TAG_OLD_P_I_N_REQ), oldPIN) - } + oldPIN?.let { tlvWriter.put(ContextSpecificTag(TAG_OLD_P_I_N_REQ), oldPIN) } val TAG_NEW_P_I_N_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NEW_P_I_N_REQ), newPIN) + tlvWriter.put(ContextSpecificTag(TAG_NEW_P_I_N_REQ), newPIN) tlvWriter.endStructure() val request: InvokeRequest = @@ -174,7 +138,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -191,39 +155,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_P_I_N_CODE: Int = 0 var PINCode_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_P_I_N_CODE)) {PINCode_decoded = tlvReader.getString(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_P_I_N_CODE)) { + PINCode_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (PINCode_decoded == null) { - throw IllegalStateException("PINCode not found in TLV") + throw IllegalStateException("PINCode not found in TLV") } - tlvReader.exitContainer() - return ResetPINResponse( - PINCode_decoded - ) + return ResetPINResponse(PINCode_decoded) } suspend fun enable(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -241,7 +197,7 @@ class AttributeListAttribute( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -255,23 +211,21 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addBonusTime(PINCode: String? - ,bonusTime: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun addBonusTime( + PINCode: String?, + bonusTime: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } val TAG_BONUS_TIME_REQ: Int = 1 - bonusTime?.let { - tlvWriter.put(ContextSpecificTag(TAG_BONUS_TIME_REQ), bonusTime) - } + bonusTime?.let { tlvWriter.put(ContextSpecificTag(TAG_BONUS_TIME_REQ), bonusTime) } tlvWriter.endStructure() val request: InvokeRequest = @@ -285,15 +239,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setScreenDailyTime(screenTime: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun setScreenDailyTime(screenTime: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 6u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SCREEN_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SCREEN_TIME_REQ), screenTime) + tlvWriter.put(ContextSpecificTag(TAG_SCREEN_TIME_REQ), screenTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -311,7 +264,7 @@ class AttributeListAttribute( val commandId: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -329,7 +282,7 @@ class AttributeListAttribute( val commandId: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -343,15 +296,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setOnDemandRatingThreshold(rating: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun setOnDemandRatingThreshold(rating: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 9u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_RATING_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) + tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) tlvWriter.endStructure() val request: InvokeRequest = @@ -365,15 +317,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setScheduledContentRatingThreshold(rating: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun setScheduledContentRatingThreshold( + rating: String, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 10u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_RATING_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) + tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) tlvWriter.endStructure() val request: InvokeRequest = @@ -386,42 +340,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -430,35 +377,37 @@ suspend fun readEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enabled attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Enabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -470,53 +419,47 @@ suspend fun readEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ondemandratings attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ondemandratings attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return OnDemandRatingsAttribute(decodedValue) } @@ -526,100 +469,96 @@ suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnDemandRatingsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnDemandRatingsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ondemandratings attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ondemandratings attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(OnDemandRatingsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(OnDemandRatingsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnDemandRatingsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnDemandRatingThresholdAttribute(): String? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnDemandRatingThresholdAttribute(): String? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ondemandratingthreshold attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ondemandratingthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -629,100 +568,96 @@ suspend fun readOnDemandRatingThresholdAttribute(): String? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ondemandratingthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ondemandratingthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduledcontentratings attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scheduledcontentratings attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ScheduledContentRatingsAttribute(decodedValue) } @@ -732,100 +667,98 @@ suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ScheduledContentRatingsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ScheduledContentRatingsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduledcontentratings attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scheduledcontentratings attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ScheduledContentRatingsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ScheduledContentRatingsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ScheduledContentRatingsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScheduledContentRatingThresholdAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScheduledContentRatingThresholdAttribute(): String? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduledcontentratingthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Scheduledcontentratingthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -835,94 +768,90 @@ suspend fun readScheduledContentRatingThresholdAttribute(): String? {val ATTRIBU maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduledcontentratingthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scheduledcontentratingthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScreenDailyTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScreenDailyTimeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Screendailytime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Screendailytime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -932,94 +861,90 @@ suspend fun readScreenDailyTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Screendailytime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Screendailytime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemainingScreenTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRemainingScreenTimeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingscreentime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remainingscreentime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -1029,91 +954,86 @@ suspend fun readRemainingScreenTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingscreentime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Remainingscreentime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBlockUnratedAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBlockUnratedAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Blockunrated attribute not found in response" - } + } + + requireNotNull(attributeData) { "Blockunrated attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -1122,35 +1042,37 @@ suspend fun readBlockUnratedAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Blockunrated attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Blockunrated attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1162,49 +1084,43 @@ suspend fun readBlockUnratedAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 7u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1214,45 +1130,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1260,49 +1181,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1312,45 +1227,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1358,49 +1278,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1410,45 +1324,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1456,49 +1373,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1508,45 +1419,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1554,44 +1468,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1600,35 +1507,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1640,44 +1549,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1686,34 +1588,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1726,7 +1632,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt index e9cc7486518443..ae50ff527a8e2c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt @@ -17,125 +17,92 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherCluster(private val controller: MatterController, private val endpointId: UShort) { - class LauncherResponse( - val status: UByte, - val data: String? - ) -class AcceptHeaderAttribute( - val value: List? - ) +class ContentLauncherCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LauncherResponse(val status: UByte, val data: String?) + + class AcceptHeaderAttribute(val value: List?) sealed class AcceptHeaderAttributeSubscriptionState { - data class Success( - val value: List? - ) : AcceptHeaderAttributeSubscriptionState() - + data class Success(val value: List?) : AcceptHeaderAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptHeaderAttributeSubscriptionState() - object SubscriptionEstablished : AcceptHeaderAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptHeaderAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun launchContent(search: ContentLauncherClusterContentSearchStruct - ,autoPlay: Boolean - ,data: String? - ,playbackPreferences: ContentLauncherClusterPlaybackPreferencesStruct? - ,useCurrentContext: Boolean? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun launchContent( + search: ContentLauncherClusterContentSearchStruct, + autoPlay: Boolean, + data: String?, + playbackPreferences: ContentLauncherClusterPlaybackPreferencesStruct?, + useCurrentContext: Boolean?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -148,9 +115,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_AUTO_PLAY_REQ), autoPlay) val TAG_DATA_REQ: Int = 2 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } val TAG_PLAYBACK_PREFERENCES_REQ: Int = 3 playbackPreferences?.let { @@ -160,7 +125,7 @@ class AttributeListAttribute( val TAG_USE_CURRENT_CONTEXT_REQ: Int = 4 useCurrentContext?.let { tlvWriter.put(ContextSpecificTag(TAG_USE_CURRENT_CONTEXT_REQ), useCurrentContext) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -177,56 +142,49 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } - suspend fun launchURL(contentURL: String - ,displayString: String? - ,brandingInformation: ContentLauncherClusterBrandingInformationStruct? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun launchURL( + contentURL: String, + displayString: String?, + brandingInformation: ContentLauncherClusterBrandingInformationStruct?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -236,14 +194,12 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_CONTENT_U_R_L_REQ), contentURL) val TAG_DISPLAY_STRING_REQ: Int = 1 - displayString?.let { - tlvWriter.put(ContextSpecificTag(TAG_DISPLAY_STRING_REQ), displayString) - } + displayString?.let { tlvWriter.put(ContextSpecificTag(TAG_DISPLAY_STRING_REQ), displayString) } val TAG_BRANDING_INFORMATION_REQ: Int = 2 brandingInformation?.let { brandingInformation.toTlv(ContextSpecificTag(TAG_BRANDING_INFORMATION_REQ), tlvWriter) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -260,96 +216,81 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } -suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptheader attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptheader attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return AcceptHeaderAttribute(decodedValue) } @@ -359,100 +300,94 @@ suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptHeaderAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptHeaderAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptheader attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Acceptheader attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(AcceptHeaderAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(AcceptHeaderAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AcceptHeaderAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedStreamingProtocolsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedStreamingProtocolsAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedstreamingprotocols attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedstreamingprotocols attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -462,96 +397,92 @@ suspend fun readSupportedStreamingProtocolsAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedstreamingprotocols attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedstreamingprotocols attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -561,45 +492,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -607,49 +543,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -659,45 +589,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -705,49 +640,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -757,45 +686,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -803,49 +735,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -855,45 +781,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -901,44 +830,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -947,35 +869,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -987,44 +911,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1033,34 +950,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1073,7 +994,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt index 6eba50d64ec9c8..af0c8860f08d12 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt @@ -17,149 +17,124 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlCluster(private val controller: MatterController, private val endpointId: UShort) {class LoadControlProgramsAttribute( +class DemandResponseLoadControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LoadControlProgramsAttribute( val value: List ) sealed class LoadControlProgramsAttributeSubscriptionState { - data class Success( - val value: List - ) : LoadControlProgramsAttributeSubscriptionState() - + data class Success(val value: List) : + LoadControlProgramsAttributeSubscriptionState() + data class Error(val exception: Exception) : LoadControlProgramsAttributeSubscriptionState() - object SubscriptionEstablished : LoadControlProgramsAttributeSubscriptionState() - } -class EventsAttribute( - val value: List - ) + object SubscriptionEstablished : LoadControlProgramsAttributeSubscriptionState() + } + + class EventsAttribute(val value: List) sealed class EventsAttributeSubscriptionState { - data class Success( - val value: List - ) : EventsAttributeSubscriptionState() - + data class Success(val value: List) : + EventsAttributeSubscriptionState() + data class Error(val exception: Exception) : EventsAttributeSubscriptionState() - object SubscriptionEstablished : EventsAttributeSubscriptionState() - } -class ActiveEventsAttribute( + object SubscriptionEstablished : EventsAttributeSubscriptionState() + } + + class ActiveEventsAttribute( val value: List ) sealed class ActiveEventsAttributeSubscriptionState { - data class Success( - val value: List - ) : ActiveEventsAttributeSubscriptionState() - + data class Success(val value: List) : + ActiveEventsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveEventsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveEventsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ActiveEventsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun registerLoadControlProgramRequest(loadControlProgram: DemandResponseLoadControlClusterLoadControlProgramStruct - ,timedInvokeTimeout: Duration? = null) { + suspend fun registerLoadControlProgramRequest( + loadControlProgram: DemandResponseLoadControlClusterLoadControlProgramStruct, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LOAD_CONTROL_PROGRAM_REQ: Int = 0 - loadControlProgram.toTlv(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_REQ), tlvWriter) + loadControlProgram.toTlv(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -173,15 +148,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unregisterLoadControlProgramRequest(loadControlProgramID: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun unregisterLoadControlProgramRequest( + loadControlProgramID: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LOAD_CONTROL_PROGRAM_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_I_D_REQ), loadControlProgramID) + tlvWriter.put(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_I_D_REQ), loadControlProgramID) tlvWriter.endStructure() val request: InvokeRequest = @@ -195,15 +172,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addLoadControlEventRequest(event: DemandResponseLoadControlClusterLoadControlEventStruct - ,timedInvokeTimeout: Duration? = null) { + suspend fun addLoadControlEventRequest( + event: DemandResponseLoadControlClusterLoadControlEventStruct, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_EVENT_REQ: Int = 0 - event.toTlv(ContextSpecificTag(TAG_EVENT_REQ), tlvWriter) + event.toTlv(ContextSpecificTag(TAG_EVENT_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -217,9 +196,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun removeLoadControlEventRequest(eventID: ByteArray - ,cancelControl: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun removeLoadControlEventRequest( + eventID: ByteArray, + cancelControl: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -229,7 +210,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_EVENT_I_D_REQ), eventID) val TAG_CANCEL_CONTROL_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CANCEL_CONTROL_REQ), cancelControl) + tlvWriter.put(ContextSpecificTag(TAG_CANCEL_CONTROL_REQ), cancelControl) tlvWriter.endStructure() val request: InvokeRequest = @@ -247,7 +228,7 @@ class AttributeListAttribute( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -260,47 +241,46 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Loadcontrolprograms attribute not found in response" - } + } + + requireNotNull(attributeData) { "Loadcontrolprograms attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return LoadControlProgramsAttribute(decodedValue) } @@ -310,45 +290,55 @@ suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LoadControlProgramsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LoadControlProgramsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Loadcontrolprograms attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Loadcontrolprograms attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(LoadControlProgramsAttributeSubscriptionState.Success(decodedValue)) } @@ -356,44 +346,37 @@ suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute {va emit(LoadControlProgramsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfLoadControlProgramsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNumberOfLoadControlProgramsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofloadcontrolprograms attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofloadcontrolprograms attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -402,34 +385,38 @@ suspend fun readNumberOfLoadControlProgramsAttribute(): UByte {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofloadcontrolprograms attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofloadcontrolprograms attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -442,49 +429,45 @@ suspend fun readNumberOfLoadControlProgramsAttribute(): UByte {val ATTRIBUTE_ID: emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventsAttribute(): EventsAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventsAttribute(): EventsAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Events attribute not found in response" - } + } + + requireNotNull(attributeData) { "Events attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventsAttribute(decodedValue) } @@ -494,45 +477,53 @@ suspend fun readEventsAttribute(): EventsAttribute {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Events attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Events attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(EventsAttributeSubscriptionState.Success(decodedValue)) } @@ -540,49 +531,45 @@ suspend fun readEventsAttribute(): EventsAttribute {val ATTRIBUTE_ID: UInt = 2u emit(EventsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveEventsAttribute(): ActiveEventsAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveEventsAttribute(): ActiveEventsAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activeevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ActiveEventsAttribute(decodedValue) } @@ -592,45 +579,53 @@ suspend fun readActiveEventsAttribute(): ActiveEventsAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveEventsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveEventsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeevents attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activeevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(ActiveEventsAttributeSubscriptionState.Success(decodedValue)) } @@ -638,44 +633,37 @@ suspend fun readActiveEventsAttribute(): ActiveEventsAttribute {val ATTRIBUTE_ID emit(ActiveEventsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfEventsPerProgramAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNumberOfEventsPerProgramAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofeventsperprogram attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofeventsperprogram attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -684,34 +672,38 @@ suspend fun readNumberOfEventsPerProgramAttribute(): UByte {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofeventsperprogram attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofeventsperprogram attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -724,44 +716,37 @@ suspend fun readNumberOfEventsPerProgramAttribute(): UByte {val ATTRIBUTE_ID: UI emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfTransitionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNumberOfTransitionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberoftransitions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberoftransitions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -770,34 +755,38 @@ suspend fun readNumberOfTransitionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberoftransitions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberoftransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -810,67 +799,56 @@ suspend fun readNumberOfTransitionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultRandomStartAttribute(): UByte {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultRandomStartAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultrandomstart attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultrandomstart attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeDefaultRandomStartAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultRandomStartAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -892,7 +870,7 @@ suspend fun readDefaultRandomStartAttribute(): UByte {val ATTRIBUTE_ID: UInt = 6 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultRandomStartAttribute( @@ -900,34 +878,38 @@ suspend fun readDefaultRandomStartAttribute(): UByte {val ATTRIBUTE_ID: UInt = 6 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultrandomstart attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultrandomstart attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -940,67 +922,59 @@ suspend fun readDefaultRandomStartAttribute(): UByte {val ATTRIBUTE_ID: UInt = 6 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultRandomDurationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultRandomDurationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultrandomduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultrandomduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } suspend fun writeDefaultRandomDurationAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1022,7 +996,7 @@ suspend fun readDefaultRandomDurationAttribute(): UByte {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultRandomDurationAttribute( @@ -1030,34 +1004,38 @@ suspend fun readDefaultRandomDurationAttribute(): UByte {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultrandomduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultrandomduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1070,49 +1048,43 @@ suspend fun readDefaultRandomDurationAttribute(): UByte {val ATTRIBUTE_ID: UInt emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1122,45 +1094,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1168,49 +1145,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1220,45 +1191,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1266,49 +1242,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1318,45 +1288,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1364,49 +1337,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1416,45 +1383,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1462,44 +1432,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1508,35 +1471,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1548,44 +1513,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1594,34 +1552,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1634,7 +1596,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt index e5b5a887fd60b2..5ff9420be9baf0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt @@ -17,206 +17,150 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class DescriptorCluster(private val controller: MatterController, private val endpointId: UShort) {class DeviceTypeListAttribute( - val value: List - ) +class DescriptorCluster(private val controller: MatterController, private val endpointId: UShort) { + class DeviceTypeListAttribute(val value: List) sealed class DeviceTypeListAttributeSubscriptionState { - data class Success( - val value: List - ) : DeviceTypeListAttributeSubscriptionState() - + data class Success(val value: List) : + DeviceTypeListAttributeSubscriptionState() + data class Error(val exception: Exception) : DeviceTypeListAttributeSubscriptionState() - object SubscriptionEstablished : DeviceTypeListAttributeSubscriptionState() - } -class ServerListAttribute( - val value: List - ) + object SubscriptionEstablished : DeviceTypeListAttributeSubscriptionState() + } + + class ServerListAttribute(val value: List) sealed class ServerListAttributeSubscriptionState { - data class Success( - val value: List - ) : ServerListAttributeSubscriptionState() - + data class Success(val value: List) : ServerListAttributeSubscriptionState() + data class Error(val exception: Exception) : ServerListAttributeSubscriptionState() - object SubscriptionEstablished : ServerListAttributeSubscriptionState() - } -class ClientListAttribute( - val value: List - ) + object SubscriptionEstablished : ServerListAttributeSubscriptionState() + } + + class ClientListAttribute(val value: List) sealed class ClientListAttributeSubscriptionState { - data class Success( - val value: List - ) : ClientListAttributeSubscriptionState() - + data class Success(val value: List) : ClientListAttributeSubscriptionState() + data class Error(val exception: Exception) : ClientListAttributeSubscriptionState() - object SubscriptionEstablished : ClientListAttributeSubscriptionState() - } -class PartsListAttribute( - val value: List - ) + object SubscriptionEstablished : ClientListAttributeSubscriptionState() + } + + class PartsListAttribute(val value: List) sealed class PartsListAttributeSubscriptionState { - data class Success( - val value: List - ) : PartsListAttributeSubscriptionState() - + data class Success(val value: List) : PartsListAttributeSubscriptionState() + data class Error(val exception: Exception) : PartsListAttributeSubscriptionState() - object SubscriptionEstablished : PartsListAttributeSubscriptionState() - } -class TagListAttribute( - val value: List? - ) + object SubscriptionEstablished : PartsListAttributeSubscriptionState() + } + + class TagListAttribute(val value: List?) sealed class TagListAttributeSubscriptionState { - data class Success( - val value: List? - ) : TagListAttributeSubscriptionState() - + data class Success(val value: List?) : + TagListAttributeSubscriptionState() + data class Error(val exception: Exception) : TagListAttributeSubscriptionState() - object SubscriptionEstablished : TagListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : TagListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Devicetypelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Devicetypelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return DeviceTypeListAttribute(decodedValue) } @@ -226,45 +170,50 @@ suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DeviceTypeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DeviceTypeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Devicetypelist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Devicetypelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(DeviceTypeListAttributeSubscriptionState.Success(decodedValue)) } @@ -272,49 +221,43 @@ suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute {val ATTRIBUT emit(DeviceTypeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readServerListAttribute(): ServerListAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readServerListAttribute(): ServerListAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serverlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Serverlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ServerListAttribute(decodedValue) } @@ -324,45 +267,48 @@ suspend fun readServerListAttribute(): ServerListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ServerListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ServerListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serverlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Serverlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ServerListAttributeSubscriptionState.Success(decodedValue)) } @@ -370,49 +316,43 @@ suspend fun readServerListAttribute(): ServerListAttribute {val ATTRIBUTE_ID: UI emit(ServerListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClientListAttribute(): ClientListAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClientListAttribute(): ClientListAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clientlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clientlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ClientListAttribute(decodedValue) } @@ -422,45 +362,48 @@ suspend fun readClientListAttribute(): ClientListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ClientListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ClientListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clientlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Clientlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ClientListAttributeSubscriptionState.Success(decodedValue)) } @@ -468,49 +411,43 @@ suspend fun readClientListAttribute(): ClientListAttribute {val ATTRIBUTE_ID: UI emit(ClientListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartsListAttribute(): PartsListAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPartsListAttribute(): PartsListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partslist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partslist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return PartsListAttribute(decodedValue) } @@ -520,45 +457,48 @@ suspend fun readPartsListAttribute(): PartsListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PartsListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PartsListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partslist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Partslist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(PartsListAttributeSubscriptionState.Success(decodedValue)) } @@ -566,53 +506,47 @@ suspend fun readPartsListAttribute(): PartsListAttribute {val ATTRIBUTE_ID: UInt emit(PartsListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTagListAttribute(): TagListAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTagListAttribute(): TagListAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Taglist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Taglist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return TagListAttribute(decodedValue) } @@ -622,102 +556,96 @@ suspend fun readTagListAttribute(): TagListAttribute {val ATTRIBUTE_ID: UInt = 4 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TagListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TagListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Taglist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Taglist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(TagListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(TagListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TagListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -727,45 +655,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -773,49 +706,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -825,45 +752,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -871,49 +803,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -923,45 +849,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -969,49 +898,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1021,45 +944,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1067,44 +993,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1113,35 +1032,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1153,44 +1074,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1199,34 +1113,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1239,7 +1157,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt index cd4c766baf855c..6549ec01a70fed 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt @@ -17,131 +17,106 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.LongSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementCluster(private val controller: MatterController, private val endpointId: UShort) {class PowerAdjustmentCapabilityAttribute( +class DeviceEnergyManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class PowerAdjustmentCapabilityAttribute( val value: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct? ) sealed class PowerAdjustmentCapabilityAttributeSubscriptionState { - data class Success( - val value: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct? - ) : PowerAdjustmentCapabilityAttributeSubscriptionState() - - data class Error(val exception: Exception) : PowerAdjustmentCapabilityAttributeSubscriptionState() - - object SubscriptionEstablished : PowerAdjustmentCapabilityAttributeSubscriptionState() - } -class ForecastAttribute( - val value: DeviceEnergyManagementClusterForecastStruct? - ) + data class Success(val value: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct?) : + PowerAdjustmentCapabilityAttributeSubscriptionState() + + data class Error(val exception: Exception) : + PowerAdjustmentCapabilityAttributeSubscriptionState() + + object SubscriptionEstablished : PowerAdjustmentCapabilityAttributeSubscriptionState() + } + + class ForecastAttribute(val value: DeviceEnergyManagementClusterForecastStruct?) sealed class ForecastAttributeSubscriptionState { - data class Success( - val value: DeviceEnergyManagementClusterForecastStruct? - ) : ForecastAttributeSubscriptionState() - + data class Success(val value: DeviceEnergyManagementClusterForecastStruct?) : + ForecastAttributeSubscriptionState() + data class Error(val exception: Exception) : ForecastAttributeSubscriptionState() - object SubscriptionEstablished : ForecastAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ForecastAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun powerAdjustRequest(power: Long - ,duration: UInt - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun powerAdjustRequest( + power: Long, + duration: UInt, + cause: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -154,7 +129,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) val TAG_CAUSE_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -172,7 +147,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -186,9 +161,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startTimeAdjustRequest(requestedStartTime: UInt - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun startTimeAdjustRequest( + requestedStartTime: UInt, + cause: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -198,7 +175,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_REQUESTED_START_TIME_REQ), requestedStartTime) val TAG_CAUSE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -212,9 +189,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseRequest(duration: UInt - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun pauseRequest(duration: UInt, cause: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -224,7 +199,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) val TAG_CAUSE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -242,7 +217,7 @@ class AttributeListAttribute( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -256,10 +231,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun modifyForecastRequest(forecastID: UInt - ,slotAdjustments: List - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun modifyForecastRequest( + forecastID: UInt, + slotAdjustments: List, + cause: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -270,13 +247,13 @@ class AttributeListAttribute( val TAG_SLOT_ADJUSTMENTS_REQ: Int = 1 tlvWriter.startArray(ContextSpecificTag(TAG_SLOT_ADJUSTMENTS_REQ)) - for (item in slotAdjustments.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in slotAdjustments.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_CAUSE_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -290,9 +267,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun requestConstraintBasedForecast(constraints: List - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun requestConstraintBasedForecast( + constraints: List, + cause: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -300,13 +279,13 @@ class AttributeListAttribute( val TAG_CONSTRAINTS_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_CONSTRAINTS_REQ)) - for (item in constraints.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in constraints.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_CAUSE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -324,7 +303,7 @@ class AttributeListAttribute( val commandId: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -337,42 +316,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readESATypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readESATypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esatype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Esatype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -381,35 +353,37 @@ suspend fun readESATypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esatype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Esatype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -421,44 +395,37 @@ suspend fun readESATypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readESACanGenerateAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readESACanGenerateAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esacangenerate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Esacangenerate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -467,34 +434,38 @@ suspend fun readESACanGenerateAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esacangenerate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Esacangenerate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -507,44 +478,37 @@ suspend fun readESACanGenerateAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readESAStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readESAStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esastate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Esastate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -553,35 +517,37 @@ suspend fun readESAStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esastate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Esastate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -593,44 +559,37 @@ suspend fun readESAStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMinPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAbsMinPowerAttribute(): Long { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absminpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absminpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -639,35 +598,37 @@ suspend fun readAbsMinPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absminpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Absminpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -679,44 +640,37 @@ suspend fun readAbsMinPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 3u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMaxPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAbsMaxPowerAttribute(): Long { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absmaxpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -725,35 +679,37 @@ suspend fun readAbsMaxPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Absmaxpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -765,52 +721,46 @@ suspend fun readAbsMaxPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 4u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Poweradjustmentcapability attribute not found in response" - } + } + + requireNotNull(attributeData) { "Poweradjustmentcapability attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PowerAdjustmentCapabilityAttribute(decodedValue) } @@ -820,104 +770,105 @@ suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityA maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PowerAdjustmentCapabilityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PowerAdjustmentCapabilityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Poweradjustmentcapability attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Poweradjustmentcapability attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: DeviceEnergyManagementClusterPowerAdjustCapabilityStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(PowerAdjustmentCapabilityAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(PowerAdjustmentCapabilityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readForecastAttribute(): ForecastAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readForecastAttribute(): ForecastAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Forecast attribute not found in response" - } + } + + requireNotNull(attributeData) { "Forecast attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: DeviceEnergyManagementClusterForecastStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: DeviceEnergyManagementClusterForecastStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ForecastAttribute(decodedValue) } @@ -927,99 +878,93 @@ suspend fun readForecastAttribute(): ForecastAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ForecastAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ForecastAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Forecast attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Forecast attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: DeviceEnergyManagementClusterForecastStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ForecastAttributeSubscriptionState.Success(it)) - } - + val decodedValue: DeviceEnergyManagementClusterForecastStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ForecastAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ForecastAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOptOutStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOptOutStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Optoutstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Optoutstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1029,96 +974,90 @@ suspend fun readOptOutStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Optoutstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Optoutstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1128,45 +1067,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1174,49 +1118,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1226,45 +1164,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1272,49 +1215,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1324,45 +1261,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1370,49 +1310,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1422,45 +1356,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1468,44 +1405,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1514,35 +1444,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1554,44 +1486,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1600,34 +1525,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1640,7 +1569,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementModeCluster.kt index 7754d2662184b2..57d57908068487 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementModeCluster.kt @@ -17,154 +17,120 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) +class DeviceEnergyManagementModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +147,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +227,52 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DeviceEnergyManagementModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +280,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +319,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +361,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +442,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +450,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +583,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +591,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +689,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +740,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +786,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +837,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +883,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +932,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +978,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1027,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1066,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1108,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1147,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,7 +1191,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt index 3c04515cd4c86d..0838a9e113ed40 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt @@ -17,112 +17,85 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DiagnosticLogsCluster(private val controller: MatterController, private val endpointId: UShort) { +class DiagnosticLogsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class RetrieveLogsResponse( - val status: UByte, - val logContent: ByteArray, - val UTCTimeStamp: ULong?, + val status: UByte, + val logContent: ByteArray, + val UTCTimeStamp: ULong?, val timeSinceBoot: ULong? ) -class GeneratedCommandListAttribute( - val value: List - ) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun retrieveLogsRequest(intent: UByte - ,requestedProtocol: UByte - ,transferFileDesignator: String? - ,timedInvokeTimeout: Duration? = null): RetrieveLogsResponse { + suspend fun retrieveLogsRequest( + intent: UByte, + requestedProtocol: UByte, + transferFileDesignator: String?, + timedInvokeTimeout: Duration? = null + ): RetrieveLogsResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -137,7 +110,7 @@ class AttributeListAttribute( val TAG_TRANSFER_FILE_DESIGNATOR_REQ: Int = 2 transferFileDesignator?.let { tlvWriter.put(ContextSpecificTag(TAG_TRANSFER_FILE_DESIGNATOR_REQ), transferFileDesignator) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -154,70 +127,65 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_LOG_CONTENT: Int = 1 var logContent_decoded: ByteArray? = null - + val TAG_U_T_C_TIME_STAMP: Int = 2 var UTCTimeStamp_decoded: ULong? = null - + val TAG_TIME_SINCE_BOOT: Int = 3 var timeSinceBoot_decoded: ULong? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_LOG_CONTENT)) {logContent_decoded = tlvReader.getByteArray(tag)} - - if (tag == ContextSpecificTag(TAG_U_T_C_TIME_STAMP)) {UTCTimeStamp_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_LOG_CONTENT)) { + logContent_decoded = tlvReader.getByteArray(tag) + } + + if (tag == ContextSpecificTag(TAG_U_T_C_TIME_STAMP)) { + UTCTimeStamp_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getULong(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_TIME_SINCE_BOOT)) {timeSinceBoot_decoded = + tlvReader.getULong(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_TIME_SINCE_BOOT)) { + timeSinceBoot_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getULong(tag) - } else { - null - } - }} - - - else { + tlvReader.getULong(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (logContent_decoded == null) { - throw IllegalStateException("logContent not found in TLV") + throw IllegalStateException("logContent not found in TLV") } - - - - - tlvReader.exitContainer() @@ -228,47 +196,41 @@ class AttributeListAttribute( timeSinceBoot_decoded ) } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -278,45 +240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -324,49 +291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -376,45 +337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -422,49 +388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -474,45 +434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -520,49 +483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -572,45 +529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -618,44 +578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -664,35 +617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -704,44 +659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -750,34 +698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -790,7 +742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt index 75b1724e213003..b13261710a3be1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt @@ -17,110 +17,80 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherAlarmCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class DishwasherAlarmCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun reset(alarms: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun reset(alarms: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ALARMS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ALARMS_REQ), alarms) + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_REQ), alarms) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,15 +104,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun modifyEnabledAlarms(mask: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun modifyEnabledAlarms(mask: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_MASK_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_MASK_REQ), mask) + tlvWriter.put(ContextSpecificTag(TAG_MASK_REQ), mask) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,42 +124,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaskAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -199,35 +161,37 @@ suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mask attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Mask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -239,47 +203,41 @@ suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLatchAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLatchAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Latch attribute not found in response" - } + } + + requireNotNull(attributeData) { "Latch attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -289,91 +247,84 @@ suspend fun readLatchAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Latch attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Latch attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStateAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in response" - } + } + + requireNotNull(attributeData) { "State attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -382,35 +333,37 @@ suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "State attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -422,44 +375,37 @@ suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -468,35 +414,37 @@ suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supported attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Supported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -508,49 +456,43 @@ suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -560,45 +502,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -606,49 +553,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -658,45 +599,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -704,49 +650,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -756,45 +696,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -802,49 +745,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -854,45 +791,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -900,44 +840,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -946,35 +879,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -986,44 +921,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1032,34 +960,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1072,7 +1004,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt index b9223830ec6740..84be2a10cc560a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt @@ -17,154 +17,120 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) +class DishwasherModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +147,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +227,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +278,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +317,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +359,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +440,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +448,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +581,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +589,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +687,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +738,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +784,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +835,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +881,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +930,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +976,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1025,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1064,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1106,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1145,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,7 +1189,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt index 2823d75b137c15..5e23a7bb20c727 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt @@ -17,257 +17,218 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class DoorLockCluster(private val controller: MatterController, private val endpointId: UShort) { class GetWeekDayScheduleResponse( - val weekDayIndex: UByte, - val userIndex: UShort, - val status: UByte, - val daysMask: UByte?, - val startHour: UByte?, - val startMinute: UByte?, - val endHour: UByte?, + val weekDayIndex: UByte, + val userIndex: UShort, + val status: UByte, + val daysMask: UByte?, + val startHour: UByte?, + val startMinute: UByte?, + val endHour: UByte?, val endMinute: UByte? ) class GetYearDayScheduleResponse( - val yearDayIndex: UByte, - val userIndex: UShort, - val status: UByte, - val localStartTime: UInt?, + val yearDayIndex: UByte, + val userIndex: UShort, + val status: UByte, + val localStartTime: UInt?, val localEndTime: UInt? ) class GetHolidayScheduleResponse( - val holidayIndex: UByte, - val status: UByte, - val localStartTime: UInt?, - val localEndTime: UInt?, + val holidayIndex: UByte, + val status: UByte, + val localStartTime: UInt?, + val localEndTime: UInt?, val operatingMode: UByte? ) class GetUserResponse( - val userIndex: UShort, - val userName: String?, - val userUniqueID: UInt?, - val userStatus: UByte?, - val userType: UByte?, - val credentialRule: UByte?, - val credentials: List?, - val creatorFabricIndex: UByte?, - val lastModifiedFabricIndex: UByte?, + val userIndex: UShort, + val userName: String?, + val userUniqueID: UInt?, + val userStatus: UByte?, + val userType: UByte?, + val credentialRule: UByte?, + val credentials: List?, + val creatorFabricIndex: UByte?, + val lastModifiedFabricIndex: UByte?, val nextUserIndex: UShort? ) class SetCredentialResponse( - val status: UByte, - val userIndex: UShort?, + val status: UByte, + val userIndex: UShort?, val nextCredentialIndex: UShort? ) class GetCredentialStatusResponse( - val credentialExists: Boolean, - val userIndex: UShort?, - val creatorFabricIndex: UByte?, - val lastModifiedFabricIndex: UByte?, + val credentialExists: Boolean, + val userIndex: UShort?, + val creatorFabricIndex: UByte?, + val lastModifiedFabricIndex: UByte?, val nextCredentialIndex: UShort? ) -class LockStateAttribute( - val value: UByte? - ) + + class LockStateAttribute(val value: UByte?) sealed class LockStateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : LockStateAttributeSubscriptionState() - + data class Success(val value: UByte?) : LockStateAttributeSubscriptionState() + data class Error(val exception: Exception) : LockStateAttributeSubscriptionState() - object SubscriptionEstablished : LockStateAttributeSubscriptionState() - } -class DoorStateAttribute( - val value: UByte? - ) + object SubscriptionEstablished : LockStateAttributeSubscriptionState() + } + + class DoorStateAttribute(val value: UByte?) sealed class DoorStateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : DoorStateAttributeSubscriptionState() - + data class Success(val value: UByte?) : DoorStateAttributeSubscriptionState() + data class Error(val exception: Exception) : DoorStateAttributeSubscriptionState() - object SubscriptionEstablished : DoorStateAttributeSubscriptionState() - } -class AliroReaderVerificationKeyAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : DoorStateAttributeSubscriptionState() + } + + class AliroReaderVerificationKeyAttribute(val value: ByteArray?) sealed class AliroReaderVerificationKeyAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : AliroReaderVerificationKeyAttributeSubscriptionState() - - data class Error(val exception: Exception) : AliroReaderVerificationKeyAttributeSubscriptionState() - - object SubscriptionEstablished : AliroReaderVerificationKeyAttributeSubscriptionState() - } -class AliroReaderGroupIdentifierAttribute( - val value: ByteArray? - ) + data class Success(val value: ByteArray?) : + AliroReaderVerificationKeyAttributeSubscriptionState() + + data class Error(val exception: Exception) : + AliroReaderVerificationKeyAttributeSubscriptionState() + + object SubscriptionEstablished : AliroReaderVerificationKeyAttributeSubscriptionState() + } + + class AliroReaderGroupIdentifierAttribute(val value: ByteArray?) sealed class AliroReaderGroupIdentifierAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : AliroReaderGroupIdentifierAttributeSubscriptionState() - - data class Error(val exception: Exception) : AliroReaderGroupIdentifierAttributeSubscriptionState() - - object SubscriptionEstablished : AliroReaderGroupIdentifierAttributeSubscriptionState() - } -class AliroExpeditedTransactionSupportedProtocolVersionsAttribute( - val value: List? - ) + data class Success(val value: ByteArray?) : + AliroReaderGroupIdentifierAttributeSubscriptionState() + + data class Error(val exception: Exception) : + AliroReaderGroupIdentifierAttributeSubscriptionState() + + object SubscriptionEstablished : AliroReaderGroupIdentifierAttributeSubscriptionState() + } + + class AliroExpeditedTransactionSupportedProtocolVersionsAttribute(val value: List?) sealed class AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState { - data class Success( - val value: List? - ) : AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() - - data class Error(val exception: Exception) : AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() - - object SubscriptionEstablished : AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() - } -class AliroGroupResolvingKeyAttribute( - val value: ByteArray? - ) + data class Success(val value: List?) : + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() + + object SubscriptionEstablished : + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() + } + + class AliroGroupResolvingKeyAttribute(val value: ByteArray?) sealed class AliroGroupResolvingKeyAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : AliroGroupResolvingKeyAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : AliroGroupResolvingKeyAttributeSubscriptionState() + data class Error(val exception: Exception) : AliroGroupResolvingKeyAttributeSubscriptionState() - object SubscriptionEstablished : AliroGroupResolvingKeyAttributeSubscriptionState() - } -class AliroSupportedBLEUWBProtocolVersionsAttribute( - val value: List? - ) + object SubscriptionEstablished : AliroGroupResolvingKeyAttributeSubscriptionState() + } + + class AliroSupportedBLEUWBProtocolVersionsAttribute(val value: List?) sealed class AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState { - data class Success( - val value: List? - ) : AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() - - data class Error(val exception: Exception) : AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() - - object SubscriptionEstablished : AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List?) : + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() + + object SubscriptionEstablished : + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun lockDoor(PINCode: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun lockDoor(PINCode: ByteArray?, timedInvokeTimeout: Duration) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } tlvWriter.endStructure() val request: InvokeRequest = @@ -281,17 +242,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unlockDoor(PINCode: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun unlockDoor(PINCode: ByteArray?, timedInvokeTimeout: Duration) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } tlvWriter.endStructure() val request: InvokeRequest = @@ -305,9 +263,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unlockWithTimeout(timeout: UShort - ,PINCode: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun unlockWithTimeout( + timeout: UShort, + PINCode: ByteArray?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -317,9 +277,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_REQ), timeout) val TAG_P_I_N_CODE_REQ: Int = 1 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } tlvWriter.endStructure() val request: InvokeRequest = @@ -333,14 +291,16 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setWeekDaySchedule(weekDayIndex: UByte - ,userIndex: UShort - ,daysMask: UByte - ,startHour: UByte - ,startMinute: UByte - ,endHour: UByte - ,endMinute: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun setWeekDaySchedule( + weekDayIndex: UByte, + userIndex: UShort, + daysMask: UByte, + startHour: UByte, + startMinute: UByte, + endHour: UByte, + endMinute: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 11u val tlvWriter = TlvWriter() @@ -365,7 +325,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_END_HOUR_REQ), endHour) val TAG_END_MINUTE_REQ: Int = 6 - tlvWriter.put(ContextSpecificTag(TAG_END_MINUTE_REQ), endMinute) + tlvWriter.put(ContextSpecificTag(TAG_END_MINUTE_REQ), endMinute) tlvWriter.endStructure() val request: InvokeRequest = @@ -379,9 +339,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getWeekDaySchedule(weekDayIndex: UByte - ,userIndex: UShort - ,timedInvokeTimeout: Duration? = null): GetWeekDayScheduleResponse { + suspend fun getWeekDaySchedule( + weekDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeout: Duration? = null + ): GetWeekDayScheduleResponse { val commandId: UInt = 12u val tlvWriter = TlvWriter() @@ -391,7 +353,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_WEEK_DAY_INDEX_REQ), weekDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -408,131 +370,127 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_WEEK_DAY_INDEX: Int = 0 var weekDayIndex_decoded: UByte? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_STATUS: Int = 2 var status_decoded: UByte? = null - + val TAG_DAYS_MASK: Int = 3 var daysMask_decoded: UByte? = null - + val TAG_START_HOUR: Int = 4 var startHour_decoded: UByte? = null - + val TAG_START_MINUTE: Int = 5 var startMinute_decoded: UByte? = null - + val TAG_END_HOUR: Int = 6 var endHour_decoded: UByte? = null - + val TAG_END_MINUTE: Int = 7 var endMinute_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_WEEK_DAY_INDEX)) {weekDayIndex_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DAYS_MASK)) {daysMask_decoded = + if (tag == ContextSpecificTag(TAG_WEEK_DAY_INDEX)) { + weekDayIndex_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DAYS_MASK)) { + daysMask_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_START_HOUR)) {startHour_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_START_HOUR)) { + startHour_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_START_MINUTE)) {startMinute_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_START_MINUTE)) { + startMinute_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_END_HOUR)) {endHour_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_END_HOUR)) { + endHour_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_END_MINUTE)) {endMinute_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_END_MINUTE)) { + endMinute_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - - else { + tlvReader.getUByte(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (weekDayIndex_decoded == null) { - throw IllegalStateException("weekDayIndex not found in TLV") + throw IllegalStateException("weekDayIndex not found in TLV") } - - + if (userIndex_decoded == null) { - throw IllegalStateException("userIndex not found in TLV") + throw IllegalStateException("userIndex not found in TLV") } - - + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") - } - - - - - - - - - - - + throw IllegalStateException("status not found in TLV") + } tlvReader.exitContainer() @@ -548,9 +506,11 @@ class AttributeListAttribute( ) } - suspend fun clearWeekDaySchedule(weekDayIndex: UByte - ,userIndex: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun clearWeekDaySchedule( + weekDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 13u val tlvWriter = TlvWriter() @@ -560,7 +520,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_WEEK_DAY_INDEX_REQ), weekDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -574,11 +534,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setYearDaySchedule(yearDayIndex: UByte - ,userIndex: UShort - ,localStartTime: UInt - ,localEndTime: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun setYearDaySchedule( + yearDayIndex: UByte, + userIndex: UShort, + localStartTime: UInt, + localEndTime: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 14u val tlvWriter = TlvWriter() @@ -594,7 +556,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_LOCAL_START_TIME_REQ), localStartTime) val TAG_LOCAL_END_TIME_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) + tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -608,9 +570,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getYearDaySchedule(yearDayIndex: UByte - ,userIndex: UShort - ,timedInvokeTimeout: Duration? = null): GetYearDayScheduleResponse { + suspend fun getYearDaySchedule( + yearDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeout: Duration? = null + ): GetYearDayScheduleResponse { val commandId: UInt = 15u val tlvWriter = TlvWriter() @@ -620,7 +584,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_YEAR_DAY_INDEX_REQ), yearDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -637,80 +601,76 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_YEAR_DAY_INDEX: Int = 0 var yearDayIndex_decoded: UByte? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_STATUS: Int = 2 var status_decoded: UByte? = null - + val TAG_LOCAL_START_TIME: Int = 3 var localStartTime_decoded: UInt? = null - + val TAG_LOCAL_END_TIME: Int = 4 var localEndTime_decoded: UInt? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_YEAR_DAY_INDEX)) {yearDayIndex_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) {localStartTime_decoded = + if (tag == ContextSpecificTag(TAG_YEAR_DAY_INDEX)) { + yearDayIndex_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) { + localStartTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) {localEndTime_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) { + localEndTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - - else { + tlvReader.getUInt(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (yearDayIndex_decoded == null) { - throw IllegalStateException("yearDayIndex not found in TLV") + throw IllegalStateException("yearDayIndex not found in TLV") } - - + if (userIndex_decoded == null) { - throw IllegalStateException("userIndex not found in TLV") + throw IllegalStateException("userIndex not found in TLV") } - - + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - tlvReader.exitContainer() @@ -723,9 +683,11 @@ class AttributeListAttribute( ) } - suspend fun clearYearDaySchedule(yearDayIndex: UByte - ,userIndex: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun clearYearDaySchedule( + yearDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 16u val tlvWriter = TlvWriter() @@ -735,7 +697,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_YEAR_DAY_INDEX_REQ), yearDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -749,11 +711,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setHolidaySchedule(holidayIndex: UByte - ,localStartTime: UInt - ,localEndTime: UInt - ,operatingMode: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun setHolidaySchedule( + holidayIndex: UByte, + localStartTime: UInt, + localEndTime: UInt, + operatingMode: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 17u val tlvWriter = TlvWriter() @@ -769,7 +733,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) val TAG_OPERATING_MODE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPERATING_MODE_REQ), operatingMode) + tlvWriter.put(ContextSpecificTag(TAG_OPERATING_MODE_REQ), operatingMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -783,15 +747,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getHolidaySchedule(holidayIndex: UByte - ,timedInvokeTimeout: Duration? = null): GetHolidayScheduleResponse { + suspend fun getHolidaySchedule( + holidayIndex: UByte, + timedInvokeTimeout: Duration? = null + ): GetHolidayScheduleResponse { val commandId: UInt = 18u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_HOLIDAY_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) + tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -808,87 +774,82 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_HOLIDAY_INDEX: Int = 0 var holidayIndex_decoded: UByte? = null - + val TAG_STATUS: Int = 1 var status_decoded: UByte? = null - + val TAG_LOCAL_START_TIME: Int = 2 var localStartTime_decoded: UInt? = null - + val TAG_LOCAL_END_TIME: Int = 3 var localEndTime_decoded: UInt? = null - + val TAG_OPERATING_MODE: Int = 4 var operatingMode_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_HOLIDAY_INDEX)) {holidayIndex_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) {localStartTime_decoded = + if (tag == ContextSpecificTag(TAG_HOLIDAY_INDEX)) { + holidayIndex_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) { + localStartTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) {localEndTime_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) { + localEndTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPERATING_MODE)) {operatingMode_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPERATING_MODE)) { + operatingMode_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - - else { + tlvReader.getUByte(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (holidayIndex_decoded == null) { - throw IllegalStateException("holidayIndex not found in TLV") + throw IllegalStateException("holidayIndex not found in TLV") } - - + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - - - tlvReader.exitContainer() @@ -901,15 +862,14 @@ class AttributeListAttribute( ) } - suspend fun clearHolidaySchedule(holidayIndex: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun clearHolidaySchedule(holidayIndex: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 19u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_HOLIDAY_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) + tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -923,14 +883,16 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setUser(operationType: UByte - ,userIndex: UShort - ,userName: String? - ,userUniqueID: UInt? - ,userStatus: UByte? - ,userType: UByte? - ,credentialRule: UByte? - ,timedInvokeTimeout: Duration) { + suspend fun setUser( + operationType: UByte, + userIndex: UShort, + userName: String?, + userUniqueID: UInt?, + userStatus: UByte?, + userType: UByte?, + credentialRule: UByte?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 26u val tlvWriter = TlvWriter() @@ -943,29 +905,21 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) val TAG_USER_NAME_REQ: Int = 2 - userName?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_NAME_REQ), userName) - } + userName?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_NAME_REQ), userName) } val TAG_USER_UNIQUE_I_D_REQ: Int = 3 - userUniqueID?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_UNIQUE_I_D_REQ), userUniqueID) - } + userUniqueID?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_UNIQUE_I_D_REQ), userUniqueID) } val TAG_USER_STATUS_REQ: Int = 4 - userStatus?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) - } + userStatus?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) } val TAG_USER_TYPE_REQ: Int = 5 - userType?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) - } + userType?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) } val TAG_CREDENTIAL_RULE_REQ: Int = 6 credentialRule?.let { tlvWriter.put(ContextSpecificTag(TAG_CREDENTIAL_RULE_REQ), credentialRule) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -979,15 +933,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getUser(userIndex: UShort - ,timedInvokeTimeout: Duration? = null): GetUserResponse { + suspend fun getUser(userIndex: UShort, timedInvokeTimeout: Duration? = null): GetUserResponse { val commandId: UInt = 27u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_USER_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -1004,194 +957,188 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_USER_INDEX: Int = 0 var userIndex_decoded: UShort? = null - + val TAG_USER_NAME: Int = 1 var userName_decoded: String? = null - + val TAG_USER_UNIQUE_I_D: Int = 2 var userUniqueID_decoded: UInt? = null - + val TAG_USER_STATUS: Int = 3 var userStatus_decoded: UByte? = null - + val TAG_USER_TYPE: Int = 4 var userType_decoded: UByte? = null - + val TAG_CREDENTIAL_RULE: Int = 5 var credentialRule_decoded: UByte? = null - + val TAG_CREDENTIALS: Int = 6 var credentials_decoded: List? = null - + val TAG_CREATOR_FABRIC_INDEX: Int = 7 var creatorFabricIndex_decoded: UByte? = null - + val TAG_LAST_MODIFIED_FABRIC_INDEX: Int = 8 var lastModifiedFabricIndex_decoded: UByte? = null - + val TAG_NEXT_USER_INDEX: Int = 9 var nextUserIndex_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_USER_NAME)) {userName_decoded = + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_NAME)) { + userName_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getString(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_USER_UNIQUE_I_D)) {userUniqueID_decoded = + tlvReader.getString(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_UNIQUE_I_D)) { + userUniqueID_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUInt(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_USER_STATUS)) {userStatus_decoded = + tlvReader.getUInt(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_STATUS)) { + userStatus_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_USER_TYPE)) {userType_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_TYPE)) { + userType_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_CREDENTIAL_RULE)) {credentialRule_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREDENTIAL_RULE)) { + credentialRule_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_CREDENTIALS)) {credentials_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREDENTIALS)) { + credentials_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) {creatorFabricIndex_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) { + creatorFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) {lastModifiedFabricIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) { + lastModifiedFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_NEXT_USER_INDEX)) {nextUserIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NEXT_USER_INDEX)) { + nextUserIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (userIndex_decoded == null) { - throw IllegalStateException("userIndex not found in TLV") - } - - - - - - - - - - - - - - - - - - - + throw IllegalStateException("userIndex not found in TLV") + } tlvReader.exitContainer() @@ -1209,15 +1156,14 @@ class AttributeListAttribute( ) } - suspend fun clearUser(userIndex: UShort - ,timedInvokeTimeout: Duration) { + suspend fun clearUser(userIndex: UShort, timedInvokeTimeout: Duration) { val commandId: UInt = 29u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_USER_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -1231,13 +1177,15 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setCredential(operationType: UByte - ,credential: DoorLockClusterCredentialStruct - ,credentialData: ByteArray - ,userIndex: UShort? - ,userStatus: UByte? - ,userType: UByte? - ,timedInvokeTimeout: Duration): SetCredentialResponse { + suspend fun setCredential( + operationType: UByte, + credential: DoorLockClusterCredentialStruct, + credentialData: ByteArray, + userIndex: UShort?, + userStatus: UByte?, + userType: UByte?, + timedInvokeTimeout: Duration + ): SetCredentialResponse { val commandId: UInt = 34u val tlvWriter = TlvWriter() @@ -1253,19 +1201,13 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_CREDENTIAL_DATA_REQ), credentialData) val TAG_USER_INDEX_REQ: Int = 3 - userIndex?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) - } + userIndex?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) } val TAG_USER_STATUS_REQ: Int = 4 - userStatus?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) - } + userStatus?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) } val TAG_USER_TYPE_REQ: Int = 5 - userType?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) - } + userType?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) } tlvWriter.endStructure() val request: InvokeRequest = @@ -1282,81 +1224,73 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_NEXT_CREDENTIAL_INDEX: Int = 2 var nextCredentialIndex_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) {nextCredentialIndex_decoded = + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) { + nextCredentialIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - tlvReader.exitContainer() - return SetCredentialResponse( - status_decoded, - userIndex_decoded, - nextCredentialIndex_decoded - ) + return SetCredentialResponse(status_decoded, userIndex_decoded, nextCredentialIndex_decoded) } - suspend fun getCredentialStatus(credential: DoorLockClusterCredentialStruct - ,timedInvokeTimeout: Duration? = null): GetCredentialStatusResponse { + suspend fun getCredentialStatus( + credential: DoorLockClusterCredentialStruct, + timedInvokeTimeout: Duration? = null + ): GetCredentialStatusResponse { val commandId: UInt = 36u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_CREDENTIAL_REQ: Int = 0 - credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) + credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1373,98 +1307,92 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_CREDENTIAL_EXISTS: Int = 0 var credentialExists_decoded: Boolean? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_CREATOR_FABRIC_INDEX: Int = 2 var creatorFabricIndex_decoded: UByte? = null - + val TAG_LAST_MODIFIED_FABRIC_INDEX: Int = 3 var lastModifiedFabricIndex_decoded: UByte? = null - + val TAG_NEXT_CREDENTIAL_INDEX: Int = 4 var nextCredentialIndex_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_CREDENTIAL_EXISTS)) {credentialExists_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = + if (tag == ContextSpecificTag(TAG_CREDENTIAL_EXISTS)) { + credentialExists_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) {creatorFabricIndex_decoded = + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) { + creatorFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) {lastModifiedFabricIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) { + lastModifiedFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) {nextCredentialIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) { + nextCredentialIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (credentialExists_decoded == null) { - throw IllegalStateException("credentialExists not found in TLV") - } - - - - - - - - - + throw IllegalStateException("credentialExists not found in TLV") + } tlvReader.exitContainer() @@ -1477,17 +1405,17 @@ class AttributeListAttribute( ) } - suspend fun clearCredential(credential: DoorLockClusterCredentialStruct? - ,timedInvokeTimeout: Duration) { + suspend fun clearCredential( + credential: DoorLockClusterCredentialStruct?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 38u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_CREDENTIAL_REQ: Int = 0 - credential?.let { - credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) - } + credential?.let { credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) } tlvWriter.endStructure() val request: InvokeRequest = @@ -1501,17 +1429,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unboltDoor(PINCode: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun unboltDoor(PINCode: ByteArray?, timedInvokeTimeout: Duration) { val commandId: UInt = 39u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } tlvWriter.endStructure() val request: InvokeRequest = @@ -1525,11 +1450,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setAliroReaderConfig(signingKey: ByteArray - ,verificationKey: ByteArray - ,groupIdentifier: ByteArray - ,groupResolvingKey: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun setAliroReaderConfig( + signingKey: ByteArray, + verificationKey: ByteArray, + groupIdentifier: ByteArray, + groupResolvingKey: ByteArray?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 40u val tlvWriter = TlvWriter() @@ -1547,7 +1474,7 @@ class AttributeListAttribute( val TAG_GROUP_RESOLVING_KEY_REQ: Int = 3 groupResolvingKey?.let { tlvWriter.put(ContextSpecificTag(TAG_GROUP_RESOLVING_KEY_REQ), groupResolvingKey) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1565,7 +1492,7 @@ class AttributeListAttribute( val commandId: UInt = 41u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -1578,46 +1505,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readLockStateAttribute(): LockStateAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLockStateAttribute(): LockStateAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lockstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lockstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LockStateAttribute(decodedValue) } @@ -1627,92 +1548,85 @@ suspend fun readLockStateAttribute(): LockStateAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LockStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LockStateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lockstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lockstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LockStateAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LockStateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LockStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLockTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLockTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Locktype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Locktype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1721,35 +1635,37 @@ suspend fun readLockTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Locktype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Locktype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1761,44 +1677,37 @@ suspend fun readLockTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActuatorEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActuatorEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 2u - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - - val response = controller.read(readRequest) + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actuatorenabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Actuatorenabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -1807,34 +1716,38 @@ suspend fun readActuatorEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actuatorenabled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Actuatorenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1847,52 +1760,46 @@ suspend fun readActuatorEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 2u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDoorStateAttribute(): DoorStateAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDoorStateAttribute(): DoorStateAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Doorstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Doorstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DoorStateAttribute(decodedValue) } @@ -1902,123 +1809,113 @@ suspend fun readDoorStateAttribute(): DoorStateAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DoorStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DoorStateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Doorstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Doorstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DoorStateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DoorStateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DoorStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDoorOpenEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDoorOpenEventsAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dooropenevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dooropenevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeDoorOpenEventsAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeDoorOpenEventsAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2040,7 +1937,7 @@ suspend fun readDoorOpenEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDoorOpenEventsAttribute( @@ -2048,118 +1945,110 @@ suspend fun readDoorOpenEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dooropenevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dooropenevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDoorClosedEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDoorClosedEventsAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Doorclosedevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Doorclosedevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeDoorClosedEventsAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeDoorClosedEventsAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2181,7 +2070,7 @@ suspend fun readDoorClosedEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDoorClosedEventsAttribute( @@ -2189,118 +2078,110 @@ suspend fun readDoorClosedEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Doorclosedevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Doorclosedevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOpenPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Openperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Openperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeOpenPeriodAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOpenPeriodAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2322,7 +2203,7 @@ suspend fun readOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOpenPeriodAttribute( @@ -2330,94 +2211,88 @@ suspend fun readOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Openperiod attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Openperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberoftotaluserssupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberoftotaluserssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2427,94 +2302,90 @@ suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberoftotaluserssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberoftotaluserssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfPINUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfPINUsersSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpinuserssupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofpinuserssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2524,94 +2395,90 @@ suspend fun readNumberOfPINUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpinuserssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofpinuserssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofrfiduserssupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofrfiduserssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2621,94 +2488,92 @@ suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofrfiduserssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofrfiduserssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofweekdayschedulessupportedperuser attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofweekdayschedulessupportedperuser attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2718,94 +2583,92 @@ suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte? {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofweekdayschedulessupportedperuser attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofweekdayschedulessupportedperuser attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofyeardayschedulessupportedperuser attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofyeardayschedulessupportedperuser attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2815,94 +2678,92 @@ suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte? {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofyeardayschedulessupportedperuser attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofyeardayschedulessupportedperuser attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofholidayschedulessupported attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofholidayschedulessupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2912,94 +2773,90 @@ suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte? {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofholidayschedulessupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofholidayschedulessupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxPINCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpincodelength attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxpincodelength attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3009,94 +2866,90 @@ suspend fun readMaxPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 23 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpincodelength attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxpincodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinPINCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minpincodelength attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minpincodelength attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3106,94 +2959,90 @@ suspend fun readMinPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 24 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minpincodelength attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minpincodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxRFIDCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxrfidcodelength attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxrfidcodelength attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3203,94 +3052,90 @@ suspend fun readMaxRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxrfidcodelength attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxrfidcodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinRFIDCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minrfidcodelength attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minrfidcodelength attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3300,94 +3145,90 @@ suspend fun readMinRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minrfidcodelength attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minrfidcodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCredentialRulesSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCredentialRulesSupportAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Credentialrulessupport attribute not found in response" - } + } + + requireNotNull(attributeData) { "Credentialrulessupport attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3397,94 +3238,92 @@ suspend fun readCredentialRulesSupportAttribute(): UByte? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Credentialrulessupport attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Credentialrulessupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofcredentialssupportedperuser attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofcredentialssupportedperuser attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3494,118 +3333,110 @@ suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofcredentialssupportedperuser attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofcredentialssupportedperuser attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLanguageAttribute(): String? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLanguageAttribute(): String? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Language attribute not found in response" - } + } + + requireNotNull(attributeData) { "Language attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLanguageAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLanguageAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3627,7 +3458,7 @@ suspend fun readLanguageAttribute(): String? {val ATTRIBUTE_ID: UInt = 33u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLanguageAttribute( @@ -3635,118 +3466,108 @@ suspend fun readLanguageAttribute(): String? {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Language attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Language attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLEDSettingsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLEDSettingsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ledsettings attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ledsettings attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLEDSettingsAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeLEDSettingsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 34u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3768,7 +3589,7 @@ suspend fun readLEDSettingsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLEDSettingsAttribute( @@ -3776,118 +3597,108 @@ suspend fun readLEDSettingsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ledsettings attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Ledsettings attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAutoRelockTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAutoRelockTimeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Autorelocktime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Autorelocktime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeAutoRelockTimeAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeAutoRelockTimeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 35u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3909,7 +3720,7 @@ suspend fun readAutoRelockTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 35u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAutoRelockTimeAttribute( @@ -3917,118 +3728,110 @@ suspend fun readAutoRelockTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 35u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Autorelocktime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Autorelocktime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoundVolumeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSoundVolumeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Soundvolume attribute not found in response" - } + } + + requireNotNull(attributeData) { "Soundvolume attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeSoundVolumeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSoundVolumeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 36u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4050,7 +3853,7 @@ suspend fun readSoundVolumeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 36u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSoundVolumeAttribute( @@ -4058,114 +3861,103 @@ suspend fun readSoundVolumeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 36u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Soundvolume attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Soundvolume attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperatingModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOperatingModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operatingmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operatingmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeOperatingModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOperatingModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 37u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4187,7 +3979,7 @@ suspend fun readOperatingModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 37u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOperatingModeAttribute( @@ -4195,35 +3987,37 @@ suspend fun readOperatingModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 37u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operatingmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Operatingmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4235,44 +4029,37 @@ suspend fun readOperatingModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 37u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedOperatingModesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSupportedOperatingModesAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedoperatingmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedoperatingmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -4281,34 +4068,38 @@ suspend fun readSupportedOperatingModesAttribute(): UShort {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedoperatingmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedoperatingmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -4321,47 +4112,41 @@ suspend fun readSupportedOperatingModesAttribute(): UShort {val ATTRIBUTE_ID: UI emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultConfigurationRegisterAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 39u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDefaultConfigurationRegisterAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultconfigurationregister attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultconfigurationregister attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4371,118 +4156,113 @@ suspend fun readDefaultConfigurationRegisterAttribute(): UShort? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultconfigurationregister attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultconfigurationregister attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnableLocalProgrammingAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 40u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnableLocalProgrammingAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enablelocalprogramming attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enablelocalprogramming attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeEnableLocalProgrammingAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 40u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4504,7 +4284,7 @@ suspend fun readEnableLocalProgrammingAttribute(): Boolean? {val ATTRIBUTE_ID: U throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnableLocalProgrammingAttribute( @@ -4512,118 +4292,113 @@ suspend fun readEnableLocalProgrammingAttribute(): Boolean? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enablelocalprogramming attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enablelocalprogramming attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnableOneTouchLockingAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnableOneTouchLockingAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableonetouchlocking attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enableonetouchlocking attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeEnableOneTouchLockingAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 41u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4645,7 +4420,7 @@ suspend fun readEnableOneTouchLockingAttribute(): Boolean? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnableOneTouchLockingAttribute( @@ -4653,118 +4428,113 @@ suspend fun readEnableOneTouchLockingAttribute(): Boolean? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableonetouchlocking attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enableonetouchlocking attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnableInsideStatusLEDAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 42u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnableInsideStatusLEDAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableinsidestatusled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enableinsidestatusled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeEnableInsideStatusLEDAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 42u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4786,7 +4556,7 @@ suspend fun readEnableInsideStatusLEDAttribute(): Boolean? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnableInsideStatusLEDAttribute( @@ -4794,118 +4564,113 @@ suspend fun readEnableInsideStatusLEDAttribute(): Boolean? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableinsidestatusled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enableinsidestatusled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 43u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 43u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableprivacymodebutton attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enableprivacymodebutton attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeEnablePrivacyModeButtonAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 43u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4927,7 +4692,7 @@ suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnablePrivacyModeButtonAttribute( @@ -4935,118 +4700,113 @@ suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 43u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableprivacymodebutton attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enableprivacymodebutton attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocalProgrammingFeaturesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 44u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocalProgrammingFeaturesAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 44u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localprogrammingfeatures attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localprogrammingfeatures attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeLocalProgrammingFeaturesAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 44u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5068,7 +4828,7 @@ suspend fun readLocalProgrammingFeaturesAttribute(): UByte? {val ATTRIBUTE_ID: U throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocalProgrammingFeaturesAttribute( @@ -5076,118 +4836,110 @@ suspend fun readLocalProgrammingFeaturesAttribute(): UByte? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 44u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localprogrammingfeatures attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Localprogrammingfeatures attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWrongCodeEntryLimitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWrongCodeEntryLimitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wrongcodeentrylimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wrongcodeentrylimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWrongCodeEntryLimitAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeWrongCodeEntryLimitAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5209,7 +4961,7 @@ suspend fun readWrongCodeEntryLimitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWrongCodeEntryLimitAttribute( @@ -5217,118 +4969,113 @@ suspend fun readWrongCodeEntryLimitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wrongcodeentrylimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wrongcodeentrylimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Usercodetemporarydisabletime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Usercodetemporarydisabletime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUserCodeTemporaryDisableTimeAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5350,7 +5097,7 @@ suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? {val ATTRIBUTE_I throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUserCodeTemporaryDisableTimeAttribute( @@ -5358,118 +5105,110 @@ suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Usercodetemporarydisabletime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Usercodetemporarydisabletime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSendPINOverTheAirAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSendPINOverTheAirAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sendpinovertheair attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sendpinovertheair attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeSendPINOverTheAirAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeSendPINOverTheAirAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5491,7 +5230,7 @@ suspend fun readSendPINOverTheAirAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSendPINOverTheAirAttribute( @@ -5499,118 +5238,113 @@ suspend fun readSendPINOverTheAirAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sendpinovertheair attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sendpinovertheair attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 51u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Requirepinforremoteoperation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Requirepinforremoteoperation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRequirePINforRemoteOperationAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5632,7 +5366,7 @@ suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? {val ATTRIBUTE throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRequirePINforRemoteOperationAttribute( @@ -5640,118 +5374,113 @@ suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? {val ATTRIBUTE maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Requirepinforremoteoperation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Requirepinforremoteoperation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readExpiringUserTimeoutAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 53u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readExpiringUserTimeoutAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expiringusertimeout attribute not found in response" - } + } + + requireNotNull(attributeData) { "Expiringusertimeout attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeExpiringUserTimeoutAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 53u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5773,7 +5502,7 @@ suspend fun readExpiringUserTimeoutAttribute(): UShort? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeExpiringUserTimeoutAttribute( @@ -5781,99 +5510,95 @@ suspend fun readExpiringUserTimeoutAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expiringusertimeout attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Expiringusertimeout attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroReaderVerificationKeyAttribute(): AliroReaderVerificationKeyAttribute {val ATTRIBUTE_ID: UInt = 128u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroReaderVerificationKeyAttribute(): AliroReaderVerificationKeyAttribute { + val ATTRIBUTE_ID: UInt = 128u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreaderverificationkey attribute not found in response" - } + } + + requireNotNull(attributeData) { "Aliroreaderverificationkey attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AliroReaderVerificationKeyAttribute(decodedValue) } @@ -5883,104 +5608,102 @@ suspend fun readAliroReaderVerificationKeyAttribute(): AliroReaderVerificationKe maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 128u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroReaderVerificationKeyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroReaderVerificationKeyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreaderverificationkey attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aliroreaderverificationkey attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(AliroReaderVerificationKeyAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(AliroReaderVerificationKeyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroReaderGroupIdentifierAttribute(): AliroReaderGroupIdentifierAttribute {val ATTRIBUTE_ID: UInt = 129u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroReaderGroupIdentifierAttribute(): AliroReaderGroupIdentifierAttribute { + val ATTRIBUTE_ID: UInt = 129u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreadergroupidentifier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Aliroreadergroupidentifier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AliroReaderGroupIdentifierAttribute(decodedValue) } @@ -5990,99 +5713,99 @@ suspend fun readAliroReaderGroupIdentifierAttribute(): AliroReaderGroupIdentifie maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 129u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroReaderGroupIdentifierAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroReaderGroupIdentifierAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreadergroupidentifier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aliroreadergroupidentifier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(AliroReaderGroupIdentifierAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(AliroReaderGroupIdentifierAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroReaderGroupSubIdentifierAttribute(): ByteArray? {val ATTRIBUTE_ID: UInt = 130u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroReaderGroupSubIdentifierAttribute(): ByteArray? { + val ATTRIBUTE_ID: UInt = 130u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreadergroupsubidentifier attribute not found in response" + } + + requireNotNull(attributeData) { + "Aliroreadergroupsubidentifier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - + val decodedValue: ByteArray? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } return decodedValue } @@ -6092,100 +5815,99 @@ suspend fun readAliroReaderGroupSubIdentifierAttribute(): ByteArray? {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 130u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteArraySubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreadergroupsubidentifier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aliroreadergroupsubidentifier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } + val decodedValue: ByteArray? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteArraySubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteArraySubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroExpeditedTransactionSupportedProtocolVersionsAttribute(): AliroExpeditedTransactionSupportedProtocolVersionsAttribute {val ATTRIBUTE_ID: UInt = 131u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroExpeditedTransactionSupportedProtocolVersionsAttribute(): + AliroExpeditedTransactionSupportedProtocolVersionsAttribute { + val ATTRIBUTE_ID: UInt = 131u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in response" + } + + requireNotNull(attributeData) { + "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return AliroExpeditedTransactionSupportedProtocolVersionsAttribute(decodedValue) } @@ -6195,105 +5917,110 @@ suspend fun readAliroExpeditedTransactionSupportedProtocolVersionsAttribute(): A maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 131u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { - emit(AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Success(it)) + emit( + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Success( + it + ) + ) } - } SubscriptionState.SubscriptionEstablished -> { - emit(AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.SubscriptionEstablished) + emit( + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState + .SubscriptionEstablished + ) } } - } + } } -suspend fun readAliroGroupResolvingKeyAttribute(): AliroGroupResolvingKeyAttribute {val ATTRIBUTE_ID: UInt = 132u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroGroupResolvingKeyAttribute(): AliroGroupResolvingKeyAttribute { + val ATTRIBUTE_ID: UInt = 132u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirogroupresolvingkey attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alirogroupresolvingkey attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AliroGroupResolvingKeyAttribute(decodedValue) } @@ -6303,105 +6030,104 @@ suspend fun readAliroGroupResolvingKeyAttribute(): AliroGroupResolvingKeyAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 132u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroGroupResolvingKeyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroGroupResolvingKeyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirogroupresolvingkey attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alirogroupresolvingkey attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AliroGroupResolvingKeyAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AliroGroupResolvingKeyAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AliroGroupResolvingKeyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroSupportedBLEUWBProtocolVersionsAttribute(): AliroSupportedBLEUWBProtocolVersionsAttribute {val ATTRIBUTE_ID: UInt = 133u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroSupportedBLEUWBProtocolVersionsAttribute(): + AliroSupportedBLEUWBProtocolVersionsAttribute { + val ATTRIBUTE_ID: UInt = 133u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirosupportedbleuwbprotocolversions attribute not found in response" + } + + requireNotNull(attributeData) { + "Alirosupportedbleuwbprotocolversions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return AliroSupportedBLEUWBProtocolVersionsAttribute(decodedValue) } @@ -6411,100 +6137,100 @@ suspend fun readAliroSupportedBLEUWBProtocolVersionsAttribute(): AliroSupportedB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 133u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirosupportedbleuwbprotocolversions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alirosupportedbleuwbprotocolversions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { emit(AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { - emit(AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.SubscriptionEstablished) + emit( + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.SubscriptionEstablished + ) } } - } + } } -suspend fun readAliroBLEAdvertisingVersionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 134u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroBLEAdvertisingVersionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 134u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirobleadvertisingversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alirobleadvertisingversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -6514,94 +6240,92 @@ suspend fun readAliroBLEAdvertisingVersionAttribute(): UByte? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 134u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirobleadvertisingversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alirobleadvertisingversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfAliroCredentialIssuerKeysSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 135u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfAliroCredentialIssuerKeysSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 135u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofalirocredentialissuerkeyssupported attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofalirocredentialissuerkeyssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6611,94 +6335,92 @@ suspend fun readNumberOfAliroCredentialIssuerKeysSupportedAttribute(): UShort? { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 135u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofalirocredentialissuerkeyssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofalirocredentialissuerkeyssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfAliroEndpointKeysSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 136u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfAliroEndpointKeysSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 136u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofaliroendpointkeyssupported attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofaliroendpointkeyssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6708,96 +6430,92 @@ suspend fun readNumberOfAliroEndpointKeysSupportedAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 136u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofaliroendpointkeyssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofaliroendpointkeyssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -6807,45 +6525,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6853,49 +6576,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -6905,45 +6622,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6951,49 +6673,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -7003,45 +6719,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -7049,49 +6768,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -7101,45 +6814,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -7147,44 +6863,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -7193,35 +6902,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7233,44 +6944,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -7279,34 +6983,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7319,7 +7027,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt index e8ee567241b398..64ade41965a6e9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt @@ -17,213 +17,173 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ElectricalEnergyMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class AccuracyAttribute( - val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct - ) +class ElectricalEnergyMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AccuracyAttribute(val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct) sealed class AccuracyAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct - ) : AccuracyAttributeSubscriptionState() - + data class Success(val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct) : + AccuracyAttributeSubscriptionState() + data class Error(val exception: Exception) : AccuracyAttributeSubscriptionState() - object SubscriptionEstablished : AccuracyAttributeSubscriptionState() - } -class CumulativeEnergyImportedAttribute( + object SubscriptionEstablished : AccuracyAttributeSubscriptionState() + } + + class CumulativeEnergyImportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class CumulativeEnergyImportedAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) : CumulativeEnergyImportedAttributeSubscriptionState() - - data class Error(val exception: Exception) : CumulativeEnergyImportedAttributeSubscriptionState() + data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : + CumulativeEnergyImportedAttributeSubscriptionState() - object SubscriptionEstablished : CumulativeEnergyImportedAttributeSubscriptionState() - } -class CumulativeEnergyExportedAttribute( + data class Error(val exception: Exception) : + CumulativeEnergyImportedAttributeSubscriptionState() + + object SubscriptionEstablished : CumulativeEnergyImportedAttributeSubscriptionState() + } + + class CumulativeEnergyExportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class CumulativeEnergyExportedAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) : CumulativeEnergyExportedAttributeSubscriptionState() - - data class Error(val exception: Exception) : CumulativeEnergyExportedAttributeSubscriptionState() + data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : + CumulativeEnergyExportedAttributeSubscriptionState() - object SubscriptionEstablished : CumulativeEnergyExportedAttributeSubscriptionState() - } -class PeriodicEnergyImportedAttribute( + data class Error(val exception: Exception) : + CumulativeEnergyExportedAttributeSubscriptionState() + + object SubscriptionEstablished : CumulativeEnergyExportedAttributeSubscriptionState() + } + + class PeriodicEnergyImportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class PeriodicEnergyImportedAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) : PeriodicEnergyImportedAttributeSubscriptionState() - + data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : + PeriodicEnergyImportedAttributeSubscriptionState() + data class Error(val exception: Exception) : PeriodicEnergyImportedAttributeSubscriptionState() - object SubscriptionEstablished : PeriodicEnergyImportedAttributeSubscriptionState() - } -class PeriodicEnergyExportedAttribute( + object SubscriptionEstablished : PeriodicEnergyImportedAttributeSubscriptionState() + } + + class PeriodicEnergyExportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class PeriodicEnergyExportedAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) : PeriodicEnergyExportedAttributeSubscriptionState() - + data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : + PeriodicEnergyExportedAttributeSubscriptionState() + data class Error(val exception: Exception) : PeriodicEnergyExportedAttributeSubscriptionState() - object SubscriptionEstablished : PeriodicEnergyExportedAttributeSubscriptionState() - } -class CumulativeEnergyResetAttribute( + object SubscriptionEstablished : PeriodicEnergyExportedAttributeSubscriptionState() + } + + class CumulativeEnergyResetAttribute( val value: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct? ) sealed class CumulativeEnergyResetAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct? - ) : CumulativeEnergyResetAttributeSubscriptionState() - + data class Success(val value: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct?) : + CumulativeEnergyResetAttributeSubscriptionState() + data class Error(val exception: Exception) : CumulativeEnergyResetAttributeSubscriptionState() - object SubscriptionEstablished : CumulativeEnergyResetAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : CumulativeEnergyResetAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readAccuracyAttribute(): AccuracyAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accuracy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accuracy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = + ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) return AccuracyAttribute(decodedValue) } @@ -233,39 +193,45 @@ suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AccuracyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AccuracyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accuracy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Accuracy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = + ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv( + AnonymousTag, + tlvReader + ) emit(AccuracyAttributeSubscriptionState.Success(decodedValue)) } @@ -273,52 +239,46 @@ suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = emit(AccuracyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyimported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Cumulativeenergyimported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CumulativeEnergyImportedAttribute(decodedValue) } @@ -328,104 +288,103 @@ suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAtt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CumulativeEnergyImportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CumulativeEnergyImportedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyimported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Cumulativeenergyimported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CumulativeEnergyImportedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CumulativeEnergyImportedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CumulativeEnergyImportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyexported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Cumulativeenergyexported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CumulativeEnergyExportedAttribute(decodedValue) } @@ -435,104 +394,103 @@ suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAtt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CumulativeEnergyExportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CumulativeEnergyExportedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyexported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Cumulativeenergyexported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CumulativeEnergyExportedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CumulativeEnergyExportedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CumulativeEnergyExportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Periodicenergyimported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Periodicenergyimported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeriodicEnergyImportedAttribute(decodedValue) } @@ -542,104 +500,103 @@ suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeriodicEnergyImportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeriodicEnergyImportedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Periodicenergyimported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Periodicenergyimported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeriodicEnergyImportedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeriodicEnergyImportedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeriodicEnergyImportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Periodicenergyexported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Periodicenergyexported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeriodicEnergyExportedAttribute(decodedValue) } @@ -649,104 +606,106 @@ suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeriodicEnergyExportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeriodicEnergyExportedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Periodicenergyexported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Periodicenergyexported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeriodicEnergyExportedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeriodicEnergyExportedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeriodicEnergyExportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCumulativeEnergyResetAttribute(): CumulativeEnergyResetAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCumulativeEnergyResetAttribute(): CumulativeEnergyResetAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyreset attribute not found in response" - } + } + + requireNotNull(attributeData) { "Cumulativeenergyreset attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CumulativeEnergyResetAttribute(decodedValue) } @@ -756,101 +715,100 @@ suspend fun readCumulativeEnergyResetAttribute(): CumulativeEnergyResetAttribute maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CumulativeEnergyResetAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CumulativeEnergyResetAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyreset attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Cumulativeenergyreset attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CumulativeEnergyResetAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CumulativeEnergyResetAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CumulativeEnergyResetAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -860,45 +818,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +869,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -958,45 +915,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +966,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1056,45 +1012,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,49 +1061,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1154,45 +1107,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1200,44 +1156,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1246,35 +1195,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1286,44 +1237,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1332,34 +1276,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1372,7 +1320,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt index 0fec4dc6624459..a44e1544733646 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt @@ -17,106 +17,84 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.ByteSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.ShortSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ElectricalMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ElectricalMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun getProfileInfoCommand(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -130,10 +108,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getMeasurementProfileCommand(attributeId: UShort - ,startTime: UInt - ,numberOfIntervals: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun getMeasurementProfileCommand( + attributeId: UShort, + startTime: UInt, + numberOfIntervals: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -146,7 +126,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) val TAG_NUMBER_OF_INTERVALS_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_INTERVALS_REQ), numberOfIntervals) + tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_INTERVALS_REQ), numberOfIntervals) tlvWriter.endStructure() val request: InvokeRequest = @@ -159,45 +139,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readMeasurementTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasurementTypeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementtype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementtype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -207,94 +181,90 @@ suspend fun readMeasurementTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementtype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementtype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 256u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 256u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -304,94 +274,88 @@ suspend fun readDcVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 256u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 256u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltage attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 257u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 257u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltagemin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -401,94 +365,88 @@ suspend fun readDcVoltageMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 257u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 257u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcvoltagemin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 258u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 258u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltagemax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -498,94 +456,88 @@ suspend fun readDcVoltageMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 258u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 258u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcvoltagemax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 259u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 259u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -595,94 +547,88 @@ suspend fun readDcCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 259u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 259u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 260u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 260u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrentmin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -692,94 +638,88 @@ suspend fun readDcCurrentMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 260u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 260u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dccurrentmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 261u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 261u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrentmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -789,94 +729,88 @@ suspend fun readDcCurrentMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 261u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 261u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dccurrentmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 262u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 262u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -886,94 +820,88 @@ suspend fun readDcPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 262u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 262u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 263u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 263u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpowermin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -983,94 +911,88 @@ suspend fun readDcPowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 263u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 263u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcpowermin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 264u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 264u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpowermax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1080,94 +1002,88 @@ suspend fun readDcPowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 264u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 264u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcpowermax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 512u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 512u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltagemultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1177,94 +1093,90 @@ suspend fun readDcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 512u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dcvoltagemultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 513u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 513u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagedivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltagedivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1274,94 +1186,90 @@ suspend fun readDcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 513u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagedivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dcvoltagedivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 514u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 514u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrentmultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1371,94 +1279,90 @@ suspend fun readDcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 514u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dccurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 515u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 515u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrentdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1468,94 +1372,90 @@ suspend fun readDcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 515u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentdivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dccurrentdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 516u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 516u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpowermultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1565,94 +1465,90 @@ suspend fun readDcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 516u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dcpowermultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 517u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 517u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowerdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpowerdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1662,94 +1558,90 @@ suspend fun readDcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 517 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 517u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowerdivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dcpowerdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 768u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 768u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1759,94 +1651,88 @@ suspend fun readAcFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 768u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 768u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequency attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Acfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 769u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyMinAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 769u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequencymin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1856,94 +1742,90 @@ suspend fun readAcFrequencyMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 769 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 769u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymin attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acfrequencymin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 770u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyMaxAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 770u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequencymax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1953,94 +1835,90 @@ suspend fun readAcFrequencyMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 770 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 770u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymax attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acfrequencymax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNeutralCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 771u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNeutralCurrentAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 771u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neutralcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Neutralcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2050,94 +1928,90 @@ suspend fun readNeutralCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 771 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 771u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neutralcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Neutralcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTotalActivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 772u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTotalActivePowerAttribute(): Int? { + val ATTRIBUTE_ID: UInt = 772u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalactivepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Totalactivepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } - + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2147,94 +2021,90 @@ suspend fun readTotalActivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 772u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 772u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalactivepower attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Totalactivepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(IntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(IntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTotalReactivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 773u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTotalReactivePowerAttribute(): Int? { + val ATTRIBUTE_ID: UInt = 773u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalreactivepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Totalreactivepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } - + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2244,94 +2114,90 @@ suspend fun readTotalReactivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 77 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 773u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalreactivepower attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Totalreactivepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(IntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(IntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTotalApparentPowerAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 774u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTotalApparentPowerAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 774u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalapparentpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Totalapparentpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2341,94 +2207,90 @@ suspend fun readTotalApparentPowerAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 7 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 774u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalapparentpower attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Totalapparentpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured1stHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 775u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured1stHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 775u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured1stharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured1stharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2438,94 +2300,90 @@ suspend fun readMeasured1stHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 775u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured1stharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured1stharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 776u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 776u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured3rdharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured3rdharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2535,94 +2393,90 @@ suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 776u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured3rdharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured3rdharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured5thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 777u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured5thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 777u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured5thharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured5thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2632,94 +2486,90 @@ suspend fun readMeasured5thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 777u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured5thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured5thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured7thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 778u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured7thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 778u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured7thharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured7thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2729,94 +2579,90 @@ suspend fun readMeasured7thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 778u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured7thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured7thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured9thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 779u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured9thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 779u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured9thharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured9thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2826,94 +2672,90 @@ suspend fun readMeasured9thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 779u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured9thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured9thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured11thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 780u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured11thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 780u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured11thharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured11thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2923,94 +2765,92 @@ suspend fun readMeasured11thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 780u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured11thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured11thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 781u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 781u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase1stharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase1stharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3020,94 +2860,92 @@ suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 781u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase1stharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase1stharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 782u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 782u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase3rdharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase3rdharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3117,94 +2955,92 @@ suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 782u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase3rdharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase3rdharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 783u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 783u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase5thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase5thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3214,94 +3050,92 @@ suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 783u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase5thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase5thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 784u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 784u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase7thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase7thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3311,94 +3145,92 @@ suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 784u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase7thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase7thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 785u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 785u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase9thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase9thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3408,94 +3240,92 @@ suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 785u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase9thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase9thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 786u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 786u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase11thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase11thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3505,94 +3335,90 @@ suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short? {val ATTRIBU maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 786u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase11thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase11thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1024u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1024u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequencymultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3602,94 +3428,90 @@ suspend fun readAcFrequencyMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1024u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acfrequencymultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1025u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1025u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencydivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequencydivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3699,94 +3521,90 @@ suspend fun readAcFrequencyDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1025u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencydivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acfrequencydivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerMultiplierAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1026u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerMultiplierAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1026u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powermultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powermultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3796,94 +3614,90 @@ suspend fun readPowerMultiplierAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1026 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1026u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powermultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Powermultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerDivisorAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1027u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerDivisorAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1027u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3893,94 +3707,88 @@ suspend fun readPowerDivisorAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1027u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1027u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerdivisor attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powerdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1028u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHarmonicCurrentMultiplierAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 1028u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Harmoniccurrentmultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Harmoniccurrentmultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3990,94 +3798,92 @@ suspend fun readHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1028u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Harmoniccurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Harmoniccurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1029u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 1029u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaseharmoniccurrentmultiplier attribute not found in response" + } + + requireNotNull(attributeData) { + "Phaseharmoniccurrentmultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -4087,94 +3893,90 @@ suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1029u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaseharmoniccurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Phaseharmoniccurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1280u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1280u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneousvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4184,94 +3986,90 @@ suspend fun readInstantaneousVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1280u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousvoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneousvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousLineCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1281u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousLineCurrentAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1281u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneouslinecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneouslinecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4281,94 +4079,90 @@ suspend fun readInstantaneousLineCurrentAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1281u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneouslinecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneouslinecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousActiveCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1282u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousActiveCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1282u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousactivecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneousactivecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4378,94 +4172,90 @@ suspend fun readInstantaneousActiveCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1282u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousactivecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneousactivecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousReactiveCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1283u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousReactiveCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1283u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousreactivecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneousreactivecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4475,94 +4265,90 @@ suspend fun readInstantaneousReactiveCurrentAttribute(): Short? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1283u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousreactivecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneousreactivecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1284u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousPowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1284u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneouspower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneouspower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4572,94 +4358,90 @@ suspend fun readInstantaneousPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1284u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneouspower attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneouspower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1285u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1285u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4669,94 +4451,88 @@ suspend fun readRmsVoltageAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1285u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1285u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltage attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1286u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMinAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1286u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagemin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4766,94 +4542,88 @@ suspend fun readRmsVoltageMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1286 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1286u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltagemin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1287u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMaxAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1287u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagemax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4863,94 +4633,88 @@ suspend fun readRmsVoltageMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1287 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1287u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltagemax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1288u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1288u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4960,94 +4724,88 @@ suspend fun readRmsCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1288u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1288u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmscurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1289u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMinAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1289u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentmin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5057,94 +4815,88 @@ suspend fun readRmsCurrentMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1289 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1289u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmscurrentmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1290u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMaxAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1290u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5154,94 +4906,88 @@ suspend fun readRmsCurrentMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1290 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1290u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmscurrentmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1291u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1291u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5251,94 +4997,88 @@ suspend fun readActivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1291u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1291u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1292u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1292u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowermin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5348,94 +5088,90 @@ suspend fun readActivePowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1292 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1292u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermin attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowermin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1293u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1293u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowermax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5445,94 +5181,90 @@ suspend fun readActivePowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1293 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1293u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermax attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowermax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1294u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactivePowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1294u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5542,94 +5274,88 @@ suspend fun readReactivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1294u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1294u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reactivepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApparentPowerAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1295u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApparentPowerAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1295u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Apparentpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5639,94 +5365,88 @@ suspend fun readApparentPowerAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1295 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1295u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Apparentpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerFactorAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1296u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerFactorAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 1296u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerfactor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -5736,118 +5456,113 @@ suspend fun readPowerFactorAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1296u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1296u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactor attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powerfactor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1297u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1297u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiod attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeAverageRmsVoltageMeasurementPeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1297u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5869,7 +5584,7 @@ suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAverageRmsVoltageMeasurementPeriodAttribute( @@ -5877,118 +5592,115 @@ suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1297u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1299u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1299u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounter attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounter attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeAverageRmsUnderVoltageCounterAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1299u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6010,7 +5722,7 @@ suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? {val ATTRIBUTE throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAverageRmsUnderVoltageCounterAttribute( @@ -6018,118 +5730,113 @@ suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? {val ATTRIBUTE maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1299u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounter attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounter attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1300u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1300u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsextremeovervoltageperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRmsExtremeOverVoltagePeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1300u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6151,7 +5858,7 @@ suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_I throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsExtremeOverVoltagePeriodAttribute( @@ -6159,118 +5866,113 @@ suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1300u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1301u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1301u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsextremeundervoltageperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRmsExtremeUnderVoltagePeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1301u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6292,7 +5994,7 @@ suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsExtremeUnderVoltagePeriodAttribute( @@ -6300,118 +6002,113 @@ suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1301u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSagPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1302u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSagPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1302u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagesagperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRmsVoltageSagPeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1302u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6433,7 +6130,7 @@ suspend fun readRmsVoltageSagPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsVoltageSagPeriodAttribute( @@ -6441,118 +6138,113 @@ suspend fun readRmsVoltageSagPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1302u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1303u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1303u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageswellperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRmsVoltageSwellPeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1303u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6574,7 +6266,7 @@ suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UIn throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsVoltageSwellPeriodAttribute( @@ -6582,94 +6274,90 @@ suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1303u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1536u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcVoltageMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1536u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltagemultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acvoltagemultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6679,94 +6367,90 @@ suspend fun readAcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1536u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltagemultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acvoltagemultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1537u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcVoltageDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1537u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltagedivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acvoltagedivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6776,94 +6460,90 @@ suspend fun readAcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1537u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltagedivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acvoltagedivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1538u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcCurrentMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1538u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentmultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accurrentmultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6873,94 +6553,90 @@ suspend fun readAcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1538u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1539u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcCurrentDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1539u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accurrentdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6970,94 +6646,90 @@ suspend fun readAcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1539u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentdivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accurrentdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1540u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcPowerMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1540u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acpowermultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acpowermultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7067,94 +6739,90 @@ suspend fun readAcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1540u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acpowermultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acpowermultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1541u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcPowerDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1541u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acpowerdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acpowerdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7164,118 +6832,110 @@ suspend fun readAcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 154 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1541u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acpowerdivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acpowerdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOverloadAlarmsMaskAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1792u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOverloadAlarmsMaskAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1792u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overloadalarmsmask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Overloadalarmsmask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeOverloadAlarmsMaskAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOverloadAlarmsMaskAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1792u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7297,7 +6957,7 @@ suspend fun readOverloadAlarmsMaskAttribute(): UByte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOverloadAlarmsMaskAttribute( @@ -7305,94 +6965,90 @@ suspend fun readOverloadAlarmsMaskAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1792u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overloadalarmsmask attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Overloadalarmsmask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1793u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVoltageOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1793u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Voltageoverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Voltageoverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7402,94 +7058,90 @@ suspend fun readVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 179 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1793u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Voltageoverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Voltageoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1794u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1794u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentoverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentoverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7499,118 +7151,113 @@ suspend fun readCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 179 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1794u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentoverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2048u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2048u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acoverloadalarmsmask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acoverloadalarmsmask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeAcOverloadAlarmsMaskAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 2048u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7632,7 +7279,7 @@ suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAcOverloadAlarmsMaskAttribute( @@ -7640,94 +7287,90 @@ suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2048u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acoverloadalarmsmask attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acoverloadalarmsmask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2049u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcVoltageOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2049u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltageoverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acvoltageoverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7737,94 +7380,90 @@ suspend fun readAcVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2049u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltageoverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acvoltageoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2050u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcCurrentOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2050u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentoverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accurrentoverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7834,94 +7473,90 @@ suspend fun readAcCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2050u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentoverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accurrentoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcActivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2051u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcActivePowerOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2051u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acactivepoweroverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acactivepoweroverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7931,94 +7566,90 @@ suspend fun readAcActivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2051u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acactivepoweroverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acactivepoweroverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcReactivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2052u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcReactivePowerOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2052u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acreactivepoweroverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acreactivepoweroverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8028,94 +7659,90 @@ suspend fun readAcReactivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2052u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acreactivepoweroverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acreactivepoweroverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2053u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsOverVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2053u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagermsovervoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8125,94 +7752,90 @@ suspend fun readAverageRmsOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2053u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsovervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2054u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsUnderVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2054u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagermsundervoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8222,94 +7845,90 @@ suspend fun readAverageRmsUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2054u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsundervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2055u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeOverVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2055u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsextremeovervoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8319,94 +7938,90 @@ suspend fun readRmsExtremeOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2055u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeovervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2056u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeUnderVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2056u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsextremeundervoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8416,94 +8031,90 @@ suspend fun readRmsExtremeUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2056u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeundervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSagAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2057u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSagAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2057u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesag attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagesag attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8513,94 +8124,88 @@ suspend fun readRmsVoltageSagAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2057u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2057u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesag attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltagesag attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSwellAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2058u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSwellAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2058u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswell attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageswell attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8610,94 +8215,90 @@ suspend fun readRmsVoltageSwellAttribute(): Short? {val ATTRIBUTE_ID: UInt = 205 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2058u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswell attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageswell attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLineCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2305u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLineCurrentPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2305u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linecurrentphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Linecurrentphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8707,94 +8308,90 @@ suspend fun readLineCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2305u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linecurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Linecurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2306u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveCurrentPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2306u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrentphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activecurrentphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8804,94 +8401,90 @@ suspend fun readActiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2306u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activecurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2307u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactiveCurrentPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2307u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrentphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivecurrentphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8901,94 +8494,90 @@ suspend fun readReactiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2307u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivecurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltagePhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2309u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltagePhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2309u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagephaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagephaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8998,94 +8587,90 @@ suspend fun readRmsVoltagePhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2309u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagephaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagephaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2310u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMinPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2310u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageminphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageminphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9095,94 +8680,90 @@ suspend fun readRmsVoltageMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2310u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageminphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageminphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2311u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2311u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagemaxphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9192,94 +8773,90 @@ suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2311u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagemaxphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2312u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2312u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9289,94 +8866,90 @@ suspend fun readRmsCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2312u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2313u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMinPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2313u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentminphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentminphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9386,94 +8959,90 @@ suspend fun readRmsCurrentMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2313u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentminphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentminphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2314u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2314u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmaxphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentmaxphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9483,94 +9052,90 @@ suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2314u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmaxphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentmaxphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2315u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2315u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowerphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9580,94 +9145,90 @@ suspend fun readActivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2315u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowerphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMinPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2316u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMinPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2316u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerminphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowerminphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9677,94 +9238,90 @@ suspend fun readActivePowerMinPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2316u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerminphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowerminphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMaxPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2317u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMaxPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2317u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermaxphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowermaxphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9774,94 +9331,90 @@ suspend fun readActivePowerMaxPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2317u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermaxphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowermaxphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2318u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactivePowerPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2318u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepowerphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivepowerphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9871,94 +9424,90 @@ suspend fun readReactivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2318u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepowerphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivepowerphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApparentPowerPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2319u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApparentPowerPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2319u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpowerphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Apparentpowerphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9968,94 +9517,90 @@ suspend fun readApparentPowerPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2319u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpowerphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Apparentpowerphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerFactorPhaseBAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 2320u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerFactorPhaseBAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 2320u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactorphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerfactorphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -10065,94 +9610,92 @@ suspend fun readPowerFactorPhaseBAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 23 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2320u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactorphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Powerfactorphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2321u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2321u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10162,94 +9705,92 @@ suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort? {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2321u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2322u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2322u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10259,94 +9800,92 @@ suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2322u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2323u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2323u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10356,94 +9895,92 @@ suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort? {val ATT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2323u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2324u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2324u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10453,94 +9990,92 @@ suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort? {val ATTRI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2324u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2325u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2325u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10550,94 +10085,90 @@ suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2325u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2326u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2326u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagesagperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10647,94 +10178,90 @@ suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2326u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2327u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2327u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageswellperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10744,94 +10271,90 @@ suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2327u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLineCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2561u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLineCurrentPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2561u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linecurrentphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Linecurrentphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10841,94 +10364,90 @@ suspend fun readLineCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2561u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linecurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Linecurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2562u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveCurrentPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2562u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrentphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activecurrentphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10938,94 +10457,90 @@ suspend fun readActiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2562u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activecurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2563u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactiveCurrentPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2563u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrentphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivecurrentphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11035,94 +10550,90 @@ suspend fun readReactiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2563u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivecurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltagePhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2565u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltagePhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2565u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagephasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagephasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11132,94 +10643,90 @@ suspend fun readRmsVoltagePhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2565u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagephasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagephasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2566u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMinPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2566u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageminphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageminphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11229,94 +10736,90 @@ suspend fun readRmsVoltageMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2566u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageminphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageminphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2567u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2567u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagemaxphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11326,94 +10829,90 @@ suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2567u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagemaxphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2568u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2568u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11423,94 +10922,90 @@ suspend fun readRmsCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2568u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2569u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMinPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2569u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentminphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentminphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11520,94 +11015,90 @@ suspend fun readRmsCurrentMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2569u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentminphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentminphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2570u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2570u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmaxphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentmaxphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11617,94 +11108,90 @@ suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2570u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmaxphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentmaxphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2571u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2571u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowerphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11714,94 +11201,90 @@ suspend fun readActivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2571u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowerphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMinPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2572u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMinPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2572u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerminphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowerminphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11811,94 +11294,90 @@ suspend fun readActivePowerMinPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2572u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerminphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowerminphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMaxPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2573u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMaxPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2573u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermaxphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowermaxphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11908,94 +11387,90 @@ suspend fun readActivePowerMaxPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2573u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermaxphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowermaxphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2574u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactivePowerPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2574u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepowerphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivepowerphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12005,94 +11480,90 @@ suspend fun readReactivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2574u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepowerphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivepowerphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApparentPowerPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2575u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApparentPowerPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2575u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpowerphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Apparentpowerphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12102,94 +11573,90 @@ suspend fun readApparentPowerPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2575u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpowerphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Apparentpowerphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerFactorPhaseCAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 2576u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerFactorPhaseCAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 2576u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactorphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerfactorphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -12199,94 +11666,92 @@ suspend fun readPowerFactorPhaseCAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 25 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2576u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactorphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Powerfactorphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2577u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2577u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12296,94 +11761,92 @@ suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort? {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2577u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2578u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2578u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12393,94 +11856,92 @@ suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2578u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2579u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2579u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12490,94 +11951,92 @@ suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort? {val ATT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2579u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2580u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2580u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12587,94 +12046,92 @@ suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort? {val ATTRI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2580u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2581u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2581u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12684,94 +12141,90 @@ suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2581u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2582u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2582u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagesagperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12781,94 +12234,90 @@ suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2582u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2583u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2583u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageswellperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12878,96 +12327,92 @@ suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2583u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -12977,45 +12422,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -13023,49 +12473,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -13075,45 +12519,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -13121,49 +12570,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -13173,45 +12616,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -13219,49 +12665,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -13271,45 +12711,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -13317,44 +12760,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -13363,35 +12799,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -13403,44 +12841,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -13449,34 +12880,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -13489,7 +12924,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalPowerMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalPowerMeasurementCluster.kt index 4856287ee65db5..6932934b50f103 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalPowerMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalPowerMeasurementCluster.kt @@ -17,357 +17,279 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ElectricalPowerMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class AccuracyAttribute( +class ElectricalPowerMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AccuracyAttribute( val value: List ) sealed class AccuracyAttributeSubscriptionState { data class Success( - val value: List + val value: List ) : AccuracyAttributeSubscriptionState() - + data class Error(val exception: Exception) : AccuracyAttributeSubscriptionState() - object SubscriptionEstablished : AccuracyAttributeSubscriptionState() - } -class RangesAttribute( - val value: List? - ) + object SubscriptionEstablished : AccuracyAttributeSubscriptionState() + } + + class RangesAttribute(val value: List?) sealed class RangesAttributeSubscriptionState { - data class Success( - val value: List? - ) : RangesAttributeSubscriptionState() - + data class Success(val value: List?) : + RangesAttributeSubscriptionState() + data class Error(val exception: Exception) : RangesAttributeSubscriptionState() - object SubscriptionEstablished : RangesAttributeSubscriptionState() - } -class VoltageAttribute( - val value: Long? - ) + object SubscriptionEstablished : RangesAttributeSubscriptionState() + } + + class VoltageAttribute(val value: Long?) sealed class VoltageAttributeSubscriptionState { - data class Success( - val value: Long? - ) : VoltageAttributeSubscriptionState() - + data class Success(val value: Long?) : VoltageAttributeSubscriptionState() + data class Error(val exception: Exception) : VoltageAttributeSubscriptionState() - object SubscriptionEstablished : VoltageAttributeSubscriptionState() - } -class ActiveCurrentAttribute( - val value: Long? - ) + object SubscriptionEstablished : VoltageAttributeSubscriptionState() + } + + class ActiveCurrentAttribute(val value: Long?) sealed class ActiveCurrentAttributeSubscriptionState { - data class Success( - val value: Long? - ) : ActiveCurrentAttributeSubscriptionState() - + data class Success(val value: Long?) : ActiveCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveCurrentAttributeSubscriptionState() - object SubscriptionEstablished : ActiveCurrentAttributeSubscriptionState() - } -class ReactiveCurrentAttribute( - val value: Long? - ) + object SubscriptionEstablished : ActiveCurrentAttributeSubscriptionState() + } + + class ReactiveCurrentAttribute(val value: Long?) sealed class ReactiveCurrentAttributeSubscriptionState { - data class Success( - val value: Long? - ) : ReactiveCurrentAttributeSubscriptionState() - + data class Success(val value: Long?) : ReactiveCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : ReactiveCurrentAttributeSubscriptionState() - object SubscriptionEstablished : ReactiveCurrentAttributeSubscriptionState() - } -class ApparentCurrentAttribute( - val value: Long? - ) + object SubscriptionEstablished : ReactiveCurrentAttributeSubscriptionState() + } + + class ApparentCurrentAttribute(val value: Long?) sealed class ApparentCurrentAttributeSubscriptionState { - data class Success( - val value: Long? - ) : ApparentCurrentAttributeSubscriptionState() - + data class Success(val value: Long?) : ApparentCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : ApparentCurrentAttributeSubscriptionState() - object SubscriptionEstablished : ApparentCurrentAttributeSubscriptionState() - } -class ActivePowerAttribute( - val value: Long? - ) + object SubscriptionEstablished : ApparentCurrentAttributeSubscriptionState() + } + + class ActivePowerAttribute(val value: Long?) sealed class ActivePowerAttributeSubscriptionState { - data class Success( - val value: Long? - ) : ActivePowerAttributeSubscriptionState() - + data class Success(val value: Long?) : ActivePowerAttributeSubscriptionState() + data class Error(val exception: Exception) : ActivePowerAttributeSubscriptionState() - object SubscriptionEstablished : ActivePowerAttributeSubscriptionState() - } -class ReactivePowerAttribute( - val value: Long? - ) + object SubscriptionEstablished : ActivePowerAttributeSubscriptionState() + } + + class ReactivePowerAttribute(val value: Long?) sealed class ReactivePowerAttributeSubscriptionState { - data class Success( - val value: Long? - ) : ReactivePowerAttributeSubscriptionState() - + data class Success(val value: Long?) : ReactivePowerAttributeSubscriptionState() + data class Error(val exception: Exception) : ReactivePowerAttributeSubscriptionState() - object SubscriptionEstablished : ReactivePowerAttributeSubscriptionState() - } -class ApparentPowerAttribute( - val value: Long? - ) + object SubscriptionEstablished : ReactivePowerAttributeSubscriptionState() + } + + class ApparentPowerAttribute(val value: Long?) sealed class ApparentPowerAttributeSubscriptionState { - data class Success( - val value: Long? - ) : ApparentPowerAttributeSubscriptionState() - + data class Success(val value: Long?) : ApparentPowerAttributeSubscriptionState() + data class Error(val exception: Exception) : ApparentPowerAttributeSubscriptionState() - object SubscriptionEstablished : ApparentPowerAttributeSubscriptionState() - } -class RMSVoltageAttribute( - val value: Long? - ) + object SubscriptionEstablished : ApparentPowerAttributeSubscriptionState() + } + + class RMSVoltageAttribute(val value: Long?) sealed class RMSVoltageAttributeSubscriptionState { - data class Success( - val value: Long? - ) : RMSVoltageAttributeSubscriptionState() - + data class Success(val value: Long?) : RMSVoltageAttributeSubscriptionState() + data class Error(val exception: Exception) : RMSVoltageAttributeSubscriptionState() - object SubscriptionEstablished : RMSVoltageAttributeSubscriptionState() - } -class RMSCurrentAttribute( - val value: Long? - ) + object SubscriptionEstablished : RMSVoltageAttributeSubscriptionState() + } + + class RMSCurrentAttribute(val value: Long?) sealed class RMSCurrentAttributeSubscriptionState { - data class Success( - val value: Long? - ) : RMSCurrentAttributeSubscriptionState() - + data class Success(val value: Long?) : RMSCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : RMSCurrentAttributeSubscriptionState() - object SubscriptionEstablished : RMSCurrentAttributeSubscriptionState() - } -class RMSPowerAttribute( - val value: Long? - ) + object SubscriptionEstablished : RMSCurrentAttributeSubscriptionState() + } + + class RMSPowerAttribute(val value: Long?) sealed class RMSPowerAttributeSubscriptionState { - data class Success( - val value: Long? - ) : RMSPowerAttributeSubscriptionState() - + data class Success(val value: Long?) : RMSPowerAttributeSubscriptionState() + data class Error(val exception: Exception) : RMSPowerAttributeSubscriptionState() - object SubscriptionEstablished : RMSPowerAttributeSubscriptionState() - } -class FrequencyAttribute( - val value: Long? - ) + object SubscriptionEstablished : RMSPowerAttributeSubscriptionState() + } + + class FrequencyAttribute(val value: Long?) sealed class FrequencyAttributeSubscriptionState { - data class Success( - val value: Long? - ) : FrequencyAttributeSubscriptionState() - + data class Success(val value: Long?) : FrequencyAttributeSubscriptionState() + data class Error(val exception: Exception) : FrequencyAttributeSubscriptionState() - object SubscriptionEstablished : FrequencyAttributeSubscriptionState() - } -class HarmonicCurrentsAttribute( + object SubscriptionEstablished : FrequencyAttributeSubscriptionState() + } + + class HarmonicCurrentsAttribute( val value: List? ) sealed class HarmonicCurrentsAttributeSubscriptionState { data class Success( - val value: List? + val value: List? ) : HarmonicCurrentsAttributeSubscriptionState() - + data class Error(val exception: Exception) : HarmonicCurrentsAttributeSubscriptionState() - object SubscriptionEstablished : HarmonicCurrentsAttributeSubscriptionState() - } -class HarmonicPhasesAttribute( + object SubscriptionEstablished : HarmonicCurrentsAttributeSubscriptionState() + } + + class HarmonicPhasesAttribute( val value: List? ) sealed class HarmonicPhasesAttributeSubscriptionState { data class Success( - val value: List? + val value: List? ) : HarmonicPhasesAttributeSubscriptionState() - + data class Error(val exception: Exception) : HarmonicPhasesAttributeSubscriptionState() - object SubscriptionEstablished : HarmonicPhasesAttributeSubscriptionState() - } -class PowerFactorAttribute( - val value: Long? - ) + object SubscriptionEstablished : HarmonicPhasesAttributeSubscriptionState() + } + + class PowerFactorAttribute(val value: Long?) sealed class PowerFactorAttributeSubscriptionState { - data class Success( - val value: Long? - ) : PowerFactorAttributeSubscriptionState() - + data class Success(val value: Long?) : PowerFactorAttributeSubscriptionState() + data class Error(val exception: Exception) : PowerFactorAttributeSubscriptionState() - object SubscriptionEstablished : PowerFactorAttributeSubscriptionState() - } -class NeutralCurrentAttribute( - val value: Long? - ) + object SubscriptionEstablished : PowerFactorAttributeSubscriptionState() + } + + class NeutralCurrentAttribute(val value: Long?) sealed class NeutralCurrentAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NeutralCurrentAttributeSubscriptionState() - + data class Success(val value: Long?) : NeutralCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : NeutralCurrentAttributeSubscriptionState() - object SubscriptionEstablished : NeutralCurrentAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : NeutralCurrentAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readPowerModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readPowerModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powermode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powermode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -376,35 +298,37 @@ suspend fun readPowerModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powermode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powermode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -416,44 +340,37 @@ suspend fun readPowerModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfMeasurementTypesAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfMeasurementTypesAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofmeasurementtypes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofmeasurementtypes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -462,34 +379,38 @@ suspend fun readNumberOfMeasurementTypesAttribute(): UByte {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofmeasurementtypes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofmeasurementtypes attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -502,49 +423,48 @@ suspend fun readNumberOfMeasurementTypesAttribute(): UByte {val ATTRIBUTE_ID: UI emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAccuracyAttribute(): AccuracyAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accuracy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accuracy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AccuracyAttribute(decodedValue) } @@ -554,45 +474,53 @@ suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AccuracyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AccuracyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accuracy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Accuracy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(AccuracyAttributeSubscriptionState.Success(decodedValue)) } @@ -600,53 +528,52 @@ suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = emit(AccuracyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRangesAttribute(): RangesAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRangesAttribute(): RangesAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ranges attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ranges attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterMeasurementRangeStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return RangesAttribute(decodedValue) } @@ -656,105 +583,104 @@ suspend fun readRangesAttribute(): RangesAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RangesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RangesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ranges attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Ranges attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterMeasurementRangeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(RangesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(RangesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RangesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVoltageAttribute(): VoltageAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVoltageAttribute(): VoltageAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Voltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Voltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return VoltageAttribute(decodedValue) } @@ -764,104 +690,98 @@ suspend fun readVoltageAttribute(): VoltageAttribute {val ATTRIBUTE_ID: UInt = 4 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(VoltageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + VoltageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Voltage attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Voltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(VoltageAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(VoltageAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(VoltageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveCurrentAttribute(): ActiveCurrentAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveCurrentAttribute(): ActiveCurrentAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveCurrentAttribute(decodedValue) } @@ -871,104 +791,98 @@ suspend fun readActiveCurrentAttribute(): ActiveCurrentAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactiveCurrentAttribute(): ReactiveCurrentAttribute {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactiveCurrentAttribute(): ReactiveCurrentAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ReactiveCurrentAttribute(decodedValue) } @@ -978,104 +892,100 @@ suspend fun readReactiveCurrentAttribute(): ReactiveCurrentAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ReactiveCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ReactiveCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ReactiveCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ReactiveCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ReactiveCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApparentCurrentAttribute(): ApparentCurrentAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApparentCurrentAttribute(): ApparentCurrentAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Apparentcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ApparentCurrentAttribute(decodedValue) } @@ -1085,100 +995,96 @@ suspend fun readApparentCurrentAttribute(): ApparentCurrentAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ApparentCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ApparentCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Apparentcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ApparentCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ApparentCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ApparentCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerAttribute(): ActivePowerAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerAttribute(): ActivePowerAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActivePowerAttribute(decodedValue) } @@ -1188,100 +1094,94 @@ suspend fun readActivePowerAttribute(): ActivePowerAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActivePowerAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActivePowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(ActivePowerAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ActivePowerAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActivePowerAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactivePowerAttribute(): ReactivePowerAttribute {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactivePowerAttribute(): ReactivePowerAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ReactivePowerAttribute(decodedValue) } @@ -1291,104 +1191,98 @@ suspend fun readReactivePowerAttribute(): ReactivePowerAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ReactivePowerAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ReactivePowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reactivepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ReactivePowerAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ReactivePowerAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ReactivePowerAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApparentPowerAttribute(): ApparentPowerAttribute {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApparentPowerAttribute(): ApparentPowerAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Apparentpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ApparentPowerAttribute(decodedValue) } @@ -1398,104 +1292,98 @@ suspend fun readApparentPowerAttribute(): ApparentPowerAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ApparentPowerAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ApparentPowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Apparentpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ApparentPowerAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ApparentPowerAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ApparentPowerAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRMSVoltageAttribute(): RMSVoltageAttribute {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRMSVoltageAttribute(): RMSVoltageAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return RMSVoltageAttribute(decodedValue) } @@ -1505,104 +1393,98 @@ suspend fun readRMSVoltageAttribute(): RMSVoltageAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RMSVoltageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RMSVoltageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltage attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(RMSVoltageAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RMSVoltageAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RMSVoltageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRMSCurrentAttribute(): RMSCurrentAttribute {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRMSCurrentAttribute(): RMSCurrentAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return RMSCurrentAttribute(decodedValue) } @@ -1612,104 +1494,98 @@ suspend fun readRMSCurrentAttribute(): RMSCurrentAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RMSCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RMSCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmscurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(RMSCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RMSCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RMSCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRMSPowerAttribute(): RMSPowerAttribute {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRMSPowerAttribute(): RMSPowerAttribute { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmspower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmspower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return RMSPowerAttribute(decodedValue) } @@ -1719,104 +1595,98 @@ suspend fun readRMSPowerAttribute(): RMSPowerAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RMSPowerAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RMSPowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmspower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmspower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(RMSPowerAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RMSPowerAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RMSPowerAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFrequencyAttribute(): FrequencyAttribute {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFrequencyAttribute(): FrequencyAttribute { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Frequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Frequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return FrequencyAttribute(decodedValue) } @@ -1826,110 +1696,109 @@ suspend fun readFrequencyAttribute(): FrequencyAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FrequencyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FrequencyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Frequency attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Frequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(FrequencyAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(FrequencyAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FrequencyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHarmonicCurrentsAttribute(): HarmonicCurrentsAttribute {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHarmonicCurrentsAttribute(): HarmonicCurrentsAttribute { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Harmoniccurrents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Harmoniccurrents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return HarmonicCurrentsAttribute(decodedValue) } @@ -1939,116 +1808,122 @@ suspend fun readHarmonicCurrentsAttribute(): HarmonicCurrentsAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(HarmonicCurrentsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + HarmonicCurrentsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Harmoniccurrents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Harmoniccurrents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(HarmonicCurrentsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(HarmonicCurrentsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(HarmonicCurrentsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHarmonicPhasesAttribute(): HarmonicPhasesAttribute {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHarmonicPhasesAttribute(): HarmonicPhasesAttribute { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Harmonicphases attribute not found in response" - } + } + + requireNotNull(attributeData) { "Harmonicphases attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return HarmonicPhasesAttribute(decodedValue) } @@ -2058,110 +1933,111 @@ suspend fun readHarmonicPhasesAttribute(): HarmonicPhasesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(HarmonicPhasesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + HarmonicPhasesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Harmonicphases attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Harmonicphases attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(HarmonicPhasesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(HarmonicPhasesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(HarmonicPhasesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerFactorAttribute(): PowerFactorAttribute {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerFactorAttribute(): PowerFactorAttribute { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerfactor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PowerFactorAttribute(decodedValue) } @@ -2171,104 +2047,98 @@ suspend fun readPowerFactorAttribute(): PowerFactorAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PowerFactorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PowerFactorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactor attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powerfactor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PowerFactorAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PowerFactorAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PowerFactorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNeutralCurrentAttribute(): NeutralCurrentAttribute {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNeutralCurrentAttribute(): NeutralCurrentAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neutralcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Neutralcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NeutralCurrentAttribute(decodedValue) } @@ -2278,101 +2148,97 @@ suspend fun readNeutralCurrentAttribute(): NeutralCurrentAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NeutralCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NeutralCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neutralcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Neutralcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(NeutralCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NeutralCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NeutralCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2382,45 +2248,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2428,49 +2299,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2480,45 +2345,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2526,49 +2396,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2578,45 +2442,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2624,49 +2491,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2676,45 +2537,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2722,44 +2586,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2768,35 +2625,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2808,44 +2667,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2854,34 +2706,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2894,7 +2750,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt index 0d532702cc4872..20363bff38ec5a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt @@ -17,45 +17,30 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.LongSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter @@ -63,259 +48,206 @@ class EnergyEvseCluster(private val controller: MatterController, private val en class GetTargetsResponse( val chargingTargetSchedules: List ) -class StateAttribute( - val value: UByte? - ) + + class StateAttribute(val value: UByte?) sealed class StateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StateAttributeSubscriptionState() - + data class Success(val value: UByte?) : StateAttributeSubscriptionState() + data class Error(val exception: Exception) : StateAttributeSubscriptionState() - object SubscriptionEstablished : StateAttributeSubscriptionState() - } -class ChargingEnabledUntilAttribute( - val value: UInt? - ) + object SubscriptionEstablished : StateAttributeSubscriptionState() + } + + class ChargingEnabledUntilAttribute(val value: UInt?) sealed class ChargingEnabledUntilAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : ChargingEnabledUntilAttributeSubscriptionState() - + data class Success(val value: UInt?) : ChargingEnabledUntilAttributeSubscriptionState() + data class Error(val exception: Exception) : ChargingEnabledUntilAttributeSubscriptionState() - object SubscriptionEstablished : ChargingEnabledUntilAttributeSubscriptionState() - } -class DischargingEnabledUntilAttribute( - val value: UInt? - ) + object SubscriptionEstablished : ChargingEnabledUntilAttributeSubscriptionState() + } + + class DischargingEnabledUntilAttribute(val value: UInt?) sealed class DischargingEnabledUntilAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : DischargingEnabledUntilAttributeSubscriptionState() - - data class Error(val exception: Exception) : DischargingEnabledUntilAttributeSubscriptionState() - - object SubscriptionEstablished : DischargingEnabledUntilAttributeSubscriptionState() - } -class NextChargeStartTimeAttribute( - val value: UInt? - ) + data class Success(val value: UInt?) : DischargingEnabledUntilAttributeSubscriptionState() + + data class Error(val exception: Exception) : + DischargingEnabledUntilAttributeSubscriptionState() + + object SubscriptionEstablished : DischargingEnabledUntilAttributeSubscriptionState() + } + + class NextChargeStartTimeAttribute(val value: UInt?) sealed class NextChargeStartTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NextChargeStartTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : NextChargeStartTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : NextChargeStartTimeAttributeSubscriptionState() - object SubscriptionEstablished : NextChargeStartTimeAttributeSubscriptionState() - } -class NextChargeTargetTimeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : NextChargeStartTimeAttributeSubscriptionState() + } + + class NextChargeTargetTimeAttribute(val value: UInt?) sealed class NextChargeTargetTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NextChargeTargetTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : NextChargeTargetTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : NextChargeTargetTimeAttributeSubscriptionState() - object SubscriptionEstablished : NextChargeTargetTimeAttributeSubscriptionState() - } -class NextChargeRequiredEnergyAttribute( - val value: Long? - ) + object SubscriptionEstablished : NextChargeTargetTimeAttributeSubscriptionState() + } + + class NextChargeRequiredEnergyAttribute(val value: Long?) sealed class NextChargeRequiredEnergyAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NextChargeRequiredEnergyAttributeSubscriptionState() - - data class Error(val exception: Exception) : NextChargeRequiredEnergyAttributeSubscriptionState() - - object SubscriptionEstablished : NextChargeRequiredEnergyAttributeSubscriptionState() - } -class NextChargeTargetSoCAttribute( - val value: UByte? - ) + data class Success(val value: Long?) : NextChargeRequiredEnergyAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NextChargeRequiredEnergyAttributeSubscriptionState() + + object SubscriptionEstablished : NextChargeRequiredEnergyAttributeSubscriptionState() + } + + class NextChargeTargetSoCAttribute(val value: UByte?) sealed class NextChargeTargetSoCAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NextChargeTargetSoCAttributeSubscriptionState() - + data class Success(val value: UByte?) : NextChargeTargetSoCAttributeSubscriptionState() + data class Error(val exception: Exception) : NextChargeTargetSoCAttributeSubscriptionState() - object SubscriptionEstablished : NextChargeTargetSoCAttributeSubscriptionState() - } -class ApproximateEVEfficiencyAttribute( - val value: UShort? - ) + object SubscriptionEstablished : NextChargeTargetSoCAttributeSubscriptionState() + } + + class ApproximateEVEfficiencyAttribute(val value: UShort?) sealed class ApproximateEVEfficiencyAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : ApproximateEVEfficiencyAttributeSubscriptionState() - - data class Error(val exception: Exception) : ApproximateEVEfficiencyAttributeSubscriptionState() - - object SubscriptionEstablished : ApproximateEVEfficiencyAttributeSubscriptionState() - } -class StateOfChargeAttribute( - val value: UByte? - ) + data class Success(val value: UShort?) : ApproximateEVEfficiencyAttributeSubscriptionState() + + data class Error(val exception: Exception) : + ApproximateEVEfficiencyAttributeSubscriptionState() + + object SubscriptionEstablished : ApproximateEVEfficiencyAttributeSubscriptionState() + } + + class StateOfChargeAttribute(val value: UByte?) sealed class StateOfChargeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StateOfChargeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StateOfChargeAttributeSubscriptionState() + data class Error(val exception: Exception) : StateOfChargeAttributeSubscriptionState() - object SubscriptionEstablished : StateOfChargeAttributeSubscriptionState() - } -class BatteryCapacityAttribute( - val value: Long? - ) + object SubscriptionEstablished : StateOfChargeAttributeSubscriptionState() + } + + class BatteryCapacityAttribute(val value: Long?) sealed class BatteryCapacityAttributeSubscriptionState { - data class Success( - val value: Long? - ) : BatteryCapacityAttributeSubscriptionState() - + data class Success(val value: Long?) : BatteryCapacityAttributeSubscriptionState() + data class Error(val exception: Exception) : BatteryCapacityAttributeSubscriptionState() - object SubscriptionEstablished : BatteryCapacityAttributeSubscriptionState() - } -class VehicleIDAttribute( - val value: String? - ) + object SubscriptionEstablished : BatteryCapacityAttributeSubscriptionState() + } + + class VehicleIDAttribute(val value: String?) sealed class VehicleIDAttributeSubscriptionState { - data class Success( - val value: String? - ) : VehicleIDAttributeSubscriptionState() - + data class Success(val value: String?) : VehicleIDAttributeSubscriptionState() + data class Error(val exception: Exception) : VehicleIDAttributeSubscriptionState() - object SubscriptionEstablished : VehicleIDAttributeSubscriptionState() - } -class SessionIDAttribute( - val value: UInt? - ) + object SubscriptionEstablished : VehicleIDAttributeSubscriptionState() + } + + class SessionIDAttribute(val value: UInt?) sealed class SessionIDAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : SessionIDAttributeSubscriptionState() - + data class Success(val value: UInt?) : SessionIDAttributeSubscriptionState() + data class Error(val exception: Exception) : SessionIDAttributeSubscriptionState() - object SubscriptionEstablished : SessionIDAttributeSubscriptionState() - } -class SessionDurationAttribute( - val value: UInt? - ) + object SubscriptionEstablished : SessionIDAttributeSubscriptionState() + } + + class SessionDurationAttribute(val value: UInt?) sealed class SessionDurationAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : SessionDurationAttributeSubscriptionState() - + data class Success(val value: UInt?) : SessionDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : SessionDurationAttributeSubscriptionState() - object SubscriptionEstablished : SessionDurationAttributeSubscriptionState() - } -class SessionEnergyChargedAttribute( - val value: Long? - ) + object SubscriptionEstablished : SessionDurationAttributeSubscriptionState() + } + + class SessionEnergyChargedAttribute(val value: Long?) sealed class SessionEnergyChargedAttributeSubscriptionState { - data class Success( - val value: Long? - ) : SessionEnergyChargedAttributeSubscriptionState() - + data class Success(val value: Long?) : SessionEnergyChargedAttributeSubscriptionState() + data class Error(val exception: Exception) : SessionEnergyChargedAttributeSubscriptionState() - object SubscriptionEstablished : SessionEnergyChargedAttributeSubscriptionState() - } -class SessionEnergyDischargedAttribute( - val value: Long? - ) + object SubscriptionEstablished : SessionEnergyChargedAttributeSubscriptionState() + } + + class SessionEnergyDischargedAttribute(val value: Long?) sealed class SessionEnergyDischargedAttributeSubscriptionState { - data class Success( - val value: Long? - ) : SessionEnergyDischargedAttributeSubscriptionState() - - data class Error(val exception: Exception) : SessionEnergyDischargedAttributeSubscriptionState() - - object SubscriptionEstablished : SessionEnergyDischargedAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: Long?) : SessionEnergyDischargedAttributeSubscriptionState() + + data class Error(val exception: Exception) : + SessionEnergyDischargedAttributeSubscriptionState() + + object SubscriptionEstablished : SessionEnergyDischargedAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun disable(timedInvokeTimeout: Duration) { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -329,10 +261,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableCharging(chargingEnabledUntil: UInt? - ,minimumChargeCurrent: Long - ,maximumChargeCurrent: Long - ,timedInvokeTimeout: Duration) { + suspend fun enableCharging( + chargingEnabledUntil: UInt?, + minimumChargeCurrent: Long, + maximumChargeCurrent: Long, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -347,7 +281,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MINIMUM_CHARGE_CURRENT_REQ), minimumChargeCurrent) val TAG_MAXIMUM_CHARGE_CURRENT_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_CHARGE_CURRENT_REQ), maximumChargeCurrent) + tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_CHARGE_CURRENT_REQ), maximumChargeCurrent) tlvWriter.endStructure() val request: InvokeRequest = @@ -361,9 +295,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableDischarging(dischargingEnabledUntil: UInt? - ,maximumDischargeCurrent: Long - ,timedInvokeTimeout: Duration) { + suspend fun enableDischarging( + dischargingEnabledUntil: UInt?, + maximumDischargeCurrent: Long, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -375,7 +311,7 @@ class AttributeListAttribute( } val TAG_MAXIMUM_DISCHARGE_CURRENT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_DISCHARGE_CURRENT_REQ), maximumDischargeCurrent) + tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_DISCHARGE_CURRENT_REQ), maximumDischargeCurrent) tlvWriter.endStructure() val request: InvokeRequest = @@ -393,7 +329,7 @@ class AttributeListAttribute( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -407,8 +343,10 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTargets(chargingTargetSchedules: List - ,timedInvokeTimeout: Duration) { + suspend fun setTargets( + chargingTargetSchedules: List, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -416,10 +354,10 @@ class AttributeListAttribute( val TAG_CHARGING_TARGET_SCHEDULES_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_CHARGING_TARGET_SCHEDULES_REQ)) - for (item in chargingTargetSchedules.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in chargingTargetSchedules.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -437,7 +375,7 @@ class AttributeListAttribute( val commandId: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -454,45 +392,38 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_CHARGING_TARGET_SCHEDULES: Int = 0 var chargingTargetSchedules_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_CHARGING_TARGET_SCHEDULES)) {chargingTargetSchedules_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseClusterChargingTargetScheduleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }} - - - else { + if (tag == ContextSpecificTag(TAG_CHARGING_TARGET_SCHEDULES)) { + chargingTargetSchedules_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (chargingTargetSchedules_decoded == null) { - throw IllegalStateException("chargingTargetSchedules not found in TLV") + throw IllegalStateException("chargingTargetSchedules not found in TLV") } - tlvReader.exitContainer() - return GetTargetsResponse( - chargingTargetSchedules_decoded - ) + return GetTargetsResponse(chargingTargetSchedules_decoded) } suspend fun clearTargets(timedInvokeTimeout: Duration) { val commandId: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -505,46 +436,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readStateAttribute(): StateAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStateAttribute(): StateAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in response" - } + } + + requireNotNull(attributeData) { "State attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return StateAttribute(decodedValue) } @@ -554,92 +479,85 @@ suspend fun readStateAttribute(): StateAttribute {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "State attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(StateAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupplyStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSupplyStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supplystate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supplystate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -648,35 +566,37 @@ suspend fun readSupplyStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supplystate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Supplystate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -688,44 +608,37 @@ suspend fun readSupplyStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFaultStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFaultStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Faultstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Faultstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -734,35 +647,37 @@ suspend fun readFaultStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Faultstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Faultstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -774,48 +689,42 @@ suspend fun readFaultStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Chargingenableduntil attribute not found in response" - } + } + + requireNotNull(attributeData) { "Chargingenableduntil attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ChargingEnabledUntilAttribute(decodedValue) } @@ -825,100 +734,96 @@ suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChargingEnabledUntilAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChargingEnabledUntilAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Chargingenableduntil attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Chargingenableduntil attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(ChargingEnabledUntilAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ChargingEnabledUntilAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChargingEnabledUntilAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dischargingenableduntil attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dischargingenableduntil attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DischargingEnabledUntilAttribute(decodedValue) } @@ -928,96 +833,91 @@ suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DischargingEnabledUntilAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DischargingEnabledUntilAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dischargingenableduntil attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dischargingenableduntil attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DischargingEnabledUntilAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DischargingEnabledUntilAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DischargingEnabledUntilAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCircuitCapacityAttribute(): Long {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCircuitCapacityAttribute(): Long { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Circuitcapacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Circuitcapacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -1026,34 +926,38 @@ suspend fun readCircuitCapacityAttribute(): Long {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Circuitcapacity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Circuitcapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1066,44 +970,37 @@ suspend fun readCircuitCapacityAttribute(): Long {val ATTRIBUTE_ID: UInt = 5u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinimumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinimumChargeCurrentAttribute(): Long { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minimumchargecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minimumchargecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -1112,34 +1009,38 @@ suspend fun readMinimumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minimumchargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minimumchargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1152,44 +1053,37 @@ suspend fun readMinimumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaximumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaximumChargeCurrentAttribute(): Long { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maximumchargecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maximumchargecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -1198,34 +1092,38 @@ suspend fun readMaximumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maximumchargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maximumchargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1238,47 +1136,41 @@ suspend fun readMaximumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaximumDischargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaximumDischargeCurrentAttribute(): Long? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maximumdischargecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maximumdischargecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } return decodedValue } @@ -1288,118 +1180,113 @@ suspend fun readMaximumDischargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maximumdischargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maximumdischargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(LongSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUserMaximumChargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUserMaximumChargeCurrentAttribute(): Long? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Usermaximumchargecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Usermaximumchargecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUserMaximumChargeCurrentAttribute( value: Long, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1421,7 +1308,7 @@ suspend fun readUserMaximumChargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUserMaximumChargeCurrentAttribute( @@ -1429,118 +1316,113 @@ suspend fun readUserMaximumChargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Usermaximumchargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Usermaximumchargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(LongSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRandomizationDelayWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRandomizationDelayWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Randomizationdelaywindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Randomizationdelaywindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRandomizationDelayWindowAttribute( value: UInt, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1562,7 +1444,7 @@ suspend fun readRandomizationDelayWindowAttribute(): UInt? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRandomizationDelayWindowAttribute( @@ -1570,99 +1452,95 @@ suspend fun readRandomizationDelayWindowAttribute(): UInt? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Randomizationdelaywindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Randomizationdelaywindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargestarttime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nextchargestarttime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NextChargeStartTimeAttribute(decodedValue) } @@ -1672,104 +1550,100 @@ suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NextChargeStartTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NextChargeStartTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargestarttime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nextchargestarttime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(NextChargeStartTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NextChargeStartTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeStartTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargetargettime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nextchargetargettime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NextChargeTargetTimeAttribute(decodedValue) } @@ -1779,104 +1653,100 @@ suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NextChargeTargetTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NextChargeTargetTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargetargettime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nextchargetargettime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(NextChargeTargetTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NextChargeTargetTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeTargetTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAttribute {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAttribute { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargerequiredenergy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nextchargerequiredenergy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NextChargeRequiredEnergyAttribute(decodedValue) } @@ -1886,104 +1756,100 @@ suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAtt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NextChargeRequiredEnergyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NextChargeRequiredEnergyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargerequiredenergy attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nextchargerequiredenergy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(NextChargeRequiredEnergyAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NextChargeRequiredEnergyAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeRequiredEnergyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargetargetsoc attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nextchargetargetsoc attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NextChargeTargetSoCAttribute(decodedValue) } @@ -1993,128 +1859,123 @@ suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NextChargeTargetSoCAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NextChargeTargetSoCAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargetargetsoc attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nextchargetargetsoc attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(NextChargeTargetSoCAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NextChargeTargetSoCAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeTargetSoCAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttribute {val ATTRIBUTE_ID: UInt = 39u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttribute { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Approximateevefficiency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Approximateevefficiency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ApproximateEVEfficiencyAttribute(decodedValue) } suspend fun writeApproximateEVEfficiencyAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 39u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2136,7 +1997,7 @@ suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttri throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeApproximateEVEfficiencyAttribute( @@ -2144,104 +2005,100 @@ suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ApproximateEVEfficiencyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ApproximateEVEfficiencyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Approximateevefficiency attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Approximateevefficiency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ApproximateEVEfficiencyAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ApproximateEVEfficiencyAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ApproximateEVEfficiencyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Stateofcharge attribute not found in response" - } + } + + requireNotNull(attributeData) { "Stateofcharge attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StateOfChargeAttribute(decodedValue) } @@ -2251,104 +2108,98 @@ suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StateOfChargeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StateOfChargeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Stateofcharge attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Stateofcharge attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StateOfChargeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StateOfChargeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StateOfChargeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batterycapacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batterycapacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatteryCapacityAttribute(decodedValue) } @@ -2358,104 +2209,100 @@ suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatteryCapacityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatteryCapacityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batterycapacity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batterycapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatteryCapacityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatteryCapacityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatteryCapacityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVehicleIDAttribute(): VehicleIDAttribute {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVehicleIDAttribute(): VehicleIDAttribute { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vehicleid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vehicleid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return VehicleIDAttribute(decodedValue) } @@ -2465,100 +2312,94 @@ suspend fun readVehicleIDAttribute(): VehicleIDAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(VehicleIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + VehicleIDAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vehicleid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vehicleid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(VehicleIDAttributeSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(VehicleIDAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(VehicleIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSessionIDAttribute(): SessionIDAttribute {val ATTRIBUTE_ID: UInt = 64u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSessionIDAttribute(): SessionIDAttribute { + val ATTRIBUTE_ID: UInt = 64u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sessionid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SessionIDAttribute(decodedValue) } @@ -2568,96 +2409,90 @@ suspend fun readSessionIDAttribute(): SessionIDAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 64u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SessionIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SessionIDAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Sessionid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(SessionIDAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(SessionIDAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SessionIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSessionDurationAttribute(): SessionDurationAttribute {val ATTRIBUTE_ID: UInt = 65u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSessionDurationAttribute(): SessionDurationAttribute { + val ATTRIBUTE_ID: UInt = 65u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sessionduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SessionDurationAttribute(decodedValue) } @@ -2667,96 +2502,92 @@ suspend fun readSessionDurationAttribute(): SessionDurationAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SessionDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SessionDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sessionduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(SessionDurationAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(SessionDurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SessionDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSessionEnergyChargedAttribute(): SessionEnergyChargedAttribute {val ATTRIBUTE_ID: UInt = 66u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSessionEnergyChargedAttribute(): SessionEnergyChargedAttribute { + val ATTRIBUTE_ID: UInt = 66u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionenergycharged attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sessionenergycharged attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SessionEnergyChargedAttribute(decodedValue) } @@ -2766,100 +2597,96 @@ suspend fun readSessionEnergyChargedAttribute(): SessionEnergyChargedAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 66u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SessionEnergyChargedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SessionEnergyChargedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionenergycharged attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sessionenergycharged attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(SessionEnergyChargedAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(SessionEnergyChargedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SessionEnergyChargedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSessionEnergyDischargedAttribute(): SessionEnergyDischargedAttribute {val ATTRIBUTE_ID: UInt = 67u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSessionEnergyDischargedAttribute(): SessionEnergyDischargedAttribute { + val ATTRIBUTE_ID: UInt = 67u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionenergydischarged attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sessionenergydischarged attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SessionEnergyDischargedAttribute(decodedValue) } @@ -2869,101 +2696,97 @@ suspend fun readSessionEnergyDischargedAttribute(): SessionEnergyDischargedAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 67u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SessionEnergyDischargedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SessionEnergyDischargedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionenergydischarged attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sessionenergydischarged attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SessionEnergyDischargedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SessionEnergyDischargedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SessionEnergyDischargedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2973,45 +2796,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3019,49 +2847,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -3071,45 +2893,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3117,49 +2944,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -3169,45 +2990,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -3215,49 +3039,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -3267,45 +3085,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -3313,44 +3134,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -3359,35 +3173,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3399,44 +3215,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -3445,34 +3254,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3485,7 +3298,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseModeCluster.kt index 43af7f34e08ac7..26111d47dac9b5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseModeCluster.kt @@ -17,154 +17,120 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) +class EnergyEvseModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +147,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +227,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +278,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +317,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +359,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +440,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +448,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +581,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +589,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +687,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +738,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +784,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +835,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +881,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +930,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +976,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1025,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1064,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1106,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1145,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,7 +1189,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt index 0ac2734058b8eb..8030bbd3cf96d0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt @@ -17,184 +17,143 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyPreferenceCluster(private val controller: MatterController, private val endpointId: UShort) {class EnergyBalancesAttribute( - val value: List? - ) +class EnergyPreferenceCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class EnergyBalancesAttribute(val value: List?) sealed class EnergyBalancesAttributeSubscriptionState { - data class Success( - val value: List? - ) : EnergyBalancesAttributeSubscriptionState() - + data class Success(val value: List?) : + EnergyBalancesAttributeSubscriptionState() + data class Error(val exception: Exception) : EnergyBalancesAttributeSubscriptionState() - object SubscriptionEstablished : EnergyBalancesAttributeSubscriptionState() - } -class EnergyPrioritiesAttribute( - val value: List? - ) + object SubscriptionEstablished : EnergyBalancesAttributeSubscriptionState() + } + + class EnergyPrioritiesAttribute(val value: List?) sealed class EnergyPrioritiesAttributeSubscriptionState { - data class Success( - val value: List? - ) : EnergyPrioritiesAttributeSubscriptionState() - + data class Success(val value: List?) : EnergyPrioritiesAttributeSubscriptionState() + data class Error(val exception: Exception) : EnergyPrioritiesAttributeSubscriptionState() - object SubscriptionEstablished : EnergyPrioritiesAttributeSubscriptionState() - } -class LowPowerModeSensitivitiesAttribute( - val value: List? - ) + object SubscriptionEstablished : EnergyPrioritiesAttributeSubscriptionState() + } + + class LowPowerModeSensitivitiesAttribute(val value: List?) sealed class LowPowerModeSensitivitiesAttributeSubscriptionState { - data class Success( - val value: List? - ) : LowPowerModeSensitivitiesAttributeSubscriptionState() - - data class Error(val exception: Exception) : LowPowerModeSensitivitiesAttributeSubscriptionState() - - object SubscriptionEstablished : LowPowerModeSensitivitiesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List?) : + LowPowerModeSensitivitiesAttributeSubscriptionState() + + data class Error(val exception: Exception) : + LowPowerModeSensitivitiesAttributeSubscriptionState() + + object SubscriptionEstablished : LowPowerModeSensitivitiesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readEnergyBalancesAttribute(): EnergyBalancesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readEnergyBalancesAttribute(): EnergyBalancesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Energybalances attribute not found in response" - } + } + + requireNotNull(attributeData) { "Energybalances attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return EnergyBalancesAttribute(decodedValue) } @@ -204,124 +163,119 @@ suspend fun readEnergyBalancesAttribute(): EnergyBalancesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EnergyBalancesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EnergyBalancesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Energybalances attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Energybalances attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(EnergyBalancesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(EnergyBalancesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(EnergyBalancesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentEnergyBalanceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentEnergyBalanceAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentenergybalance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentenergybalance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeCurrentEnergyBalanceAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -343,7 +297,7 @@ suspend fun readCurrentEnergyBalanceAttribute(): UByte? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCurrentEnergyBalanceAttribute( @@ -351,100 +305,96 @@ suspend fun readCurrentEnergyBalanceAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentenergybalance attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentenergybalance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnergyPrioritiesAttribute(): EnergyPrioritiesAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEnergyPrioritiesAttribute(): EnergyPrioritiesAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Energypriorities attribute not found in response" - } + } + + requireNotNull(attributeData) { "Energypriorities attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return EnergyPrioritiesAttribute(decodedValue) } @@ -454,106 +404,102 @@ suspend fun readEnergyPrioritiesAttribute(): EnergyPrioritiesAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EnergyPrioritiesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EnergyPrioritiesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Energypriorities attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Energypriorities attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(EnergyPrioritiesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(EnergyPrioritiesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(EnergyPrioritiesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLowPowerModeSensitivitiesAttribute(): LowPowerModeSensitivitiesAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLowPowerModeSensitivitiesAttribute(): LowPowerModeSensitivitiesAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lowpowermodesensitivities attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lowpowermodesensitivities attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return LowPowerModeSensitivitiesAttribute(decodedValue) } @@ -563,124 +509,123 @@ suspend fun readLowPowerModeSensitivitiesAttribute(): LowPowerModeSensitivitiesA maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LowPowerModeSensitivitiesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LowPowerModeSensitivitiesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lowpowermodesensitivities attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lowpowermodesensitivities attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { emit(LowPowerModeSensitivitiesAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(LowPowerModeSensitivitiesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlowpowermodesensitivity attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentlowpowermodesensitivity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeCurrentLowPowerModeSensitivityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -702,7 +647,7 @@ suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? {val ATTRIBUTE throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCurrentLowPowerModeSensitivityAttribute( @@ -710,96 +655,92 @@ suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? {val ATTRIBUTE maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlowpowermodesensitivity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentlowpowermodesensitivity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -809,45 +750,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -855,49 +801,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -907,45 +847,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -953,49 +898,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1005,45 +944,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1051,49 +993,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1103,45 +1039,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1149,44 +1088,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1195,35 +1127,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1235,44 +1169,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1281,34 +1208,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1321,7 +1252,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt index 296db7e7974d5b..42447fc0dc649a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt @@ -17,145 +17,107 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EthernetNetworkDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class PHYRateAttribute( - val value: UByte? - ) +class EthernetNetworkDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class PHYRateAttribute(val value: UByte?) sealed class PHYRateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : PHYRateAttributeSubscriptionState() - + data class Success(val value: UByte?) : PHYRateAttributeSubscriptionState() + data class Error(val exception: Exception) : PHYRateAttributeSubscriptionState() - object SubscriptionEstablished : PHYRateAttributeSubscriptionState() - } -class FullDuplexAttribute( - val value: Boolean? - ) + object SubscriptionEstablished : PHYRateAttributeSubscriptionState() + } + + class FullDuplexAttribute(val value: Boolean?) sealed class FullDuplexAttributeSubscriptionState { - data class Success( - val value: Boolean? - ) : FullDuplexAttributeSubscriptionState() - + data class Success(val value: Boolean?) : FullDuplexAttributeSubscriptionState() + data class Error(val exception: Exception) : FullDuplexAttributeSubscriptionState() - object SubscriptionEstablished : FullDuplexAttributeSubscriptionState() - } -class CarrierDetectAttribute( - val value: Boolean? - ) + object SubscriptionEstablished : FullDuplexAttributeSubscriptionState() + } + + class CarrierDetectAttribute(val value: Boolean?) sealed class CarrierDetectAttributeSubscriptionState { - data class Success( - val value: Boolean? - ) : CarrierDetectAttributeSubscriptionState() - + data class Success(val value: Boolean?) : CarrierDetectAttributeSubscriptionState() + data class Error(val exception: Exception) : CarrierDetectAttributeSubscriptionState() - object SubscriptionEstablished : CarrierDetectAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : CarrierDetectAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCounts(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -168,50 +130,44 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readPHYRateAttribute(): PHYRateAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPHYRateAttribute(): PHYRateAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phyrate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Phyrate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PHYRateAttribute(decodedValue) } @@ -221,104 +177,98 @@ suspend fun readPHYRateAttribute(): PHYRateAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PHYRateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PHYRateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phyrate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Phyrate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PHYRateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PHYRateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PHYRateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFullDuplexAttribute(): FullDuplexAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFullDuplexAttribute(): FullDuplexAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fullduplex attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fullduplex attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return FullDuplexAttribute(decodedValue) } @@ -328,99 +278,93 @@ suspend fun readFullDuplexAttribute(): FullDuplexAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FullDuplexAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FullDuplexAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fullduplex attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Fullduplex attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(FullDuplexAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(FullDuplexAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FullDuplexAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketRxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketRxCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetrxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetrxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -430,94 +374,88 @@ suspend fun readPacketRxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetrxcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Packetrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketTxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketTxCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packettxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packettxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -527,94 +465,88 @@ suspend fun readPacketTxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packettxcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Packettxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxErrCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTxErrCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txerrcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -624,94 +556,88 @@ suspend fun readTxErrCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txerrcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCollisionCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCollisionCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Collisioncount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Collisioncount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -721,94 +647,90 @@ suspend fun readCollisionCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Collisioncount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Collisioncount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOverrunCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Overruncount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -818,99 +740,93 @@ suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Overruncount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Carrierdetect attribute not found in response" - } + } + + requireNotNull(attributeData) { "Carrierdetect attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CarrierDetectAttribute(decodedValue) } @@ -920,99 +836,93 @@ suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CarrierDetectAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CarrierDetectAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Carrierdetect attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Carrierdetect attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CarrierDetectAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CarrierDetectAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CarrierDetectAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeSinceResetAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeSinceResetAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timesincereset attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timesincereset attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -1022,96 +932,92 @@ suspend fun readTimeSinceResetAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timesincereset attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Timesincereset attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1121,45 +1027,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1167,49 +1078,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1219,45 +1124,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1265,49 +1175,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1317,45 +1221,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1363,49 +1270,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1415,45 +1316,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1461,44 +1365,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1507,35 +1404,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1547,44 +1446,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1593,34 +1485,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1633,7 +1529,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt index 6d0e58a6d5b9b2..12baa895406dac 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt @@ -17,131 +17,99 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class FanControlCluster(private val controller: MatterController, private val endpointId: UShort) {class PercentSettingAttribute( - val value: UByte? - ) +class FanControlCluster(private val controller: MatterController, private val endpointId: UShort) { + class PercentSettingAttribute(val value: UByte?) sealed class PercentSettingAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : PercentSettingAttributeSubscriptionState() - + data class Success(val value: UByte?) : PercentSettingAttributeSubscriptionState() + data class Error(val exception: Exception) : PercentSettingAttributeSubscriptionState() - object SubscriptionEstablished : PercentSettingAttributeSubscriptionState() - } -class SpeedSettingAttribute( - val value: UByte? - ) + object SubscriptionEstablished : PercentSettingAttributeSubscriptionState() + } + + class SpeedSettingAttribute(val value: UByte?) sealed class SpeedSettingAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : SpeedSettingAttributeSubscriptionState() - + data class Success(val value: UByte?) : SpeedSettingAttributeSubscriptionState() + data class Error(val exception: Exception) : SpeedSettingAttributeSubscriptionState() - object SubscriptionEstablished : SpeedSettingAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SpeedSettingAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun step(direction: UByte - ,wrap: Boolean? - ,lowestOff: Boolean? - ,timedInvokeTimeout: Duration? = null) { + suspend fun step( + direction: UByte, + wrap: Boolean?, + lowestOff: Boolean?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -151,14 +119,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_DIRECTION_REQ), direction) val TAG_WRAP_REQ: Int = 1 - wrap?.let { - tlvWriter.put(ContextSpecificTag(TAG_WRAP_REQ), wrap) - } + wrap?.let { tlvWriter.put(ContextSpecificTag(TAG_WRAP_REQ), wrap) } val TAG_LOWEST_OFF_REQ: Int = 2 - lowestOff?.let { - tlvWriter.put(ContextSpecificTag(TAG_LOWEST_OFF_REQ), lowestOff) - } + lowestOff?.let { tlvWriter.put(ContextSpecificTag(TAG_LOWEST_OFF_REQ), lowestOff) } tlvWriter.endStructure() val request: InvokeRequest = @@ -171,65 +135,54 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readFanModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFanModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fanmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fanmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeFanModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeFanModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -251,7 +204,7 @@ suspend fun readFanModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFanModeAttribute( @@ -259,35 +212,37 @@ suspend fun readFanModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fanmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Fanmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -299,44 +254,37 @@ suspend fun readFanModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFanModeSequenceAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFanModeSequenceAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fanmodesequence attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fanmodesequence attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -345,34 +293,38 @@ suspend fun readFanModeSequenceAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fanmodesequence attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Fanmodesequence attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -385,72 +337,62 @@ suspend fun readFanModeSequenceAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPercentSettingAttribute(): PercentSettingAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPercentSettingAttribute(): PercentSettingAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Percentsetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Percentsetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return PercentSettingAttribute(decodedValue) } - suspend fun writePercentSettingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writePercentSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -472,7 +414,7 @@ suspend fun readPercentSettingAttribute(): PercentSettingAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePercentSettingAttribute( @@ -480,92 +422,87 @@ suspend fun readPercentSettingAttribute(): PercentSettingAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PercentSettingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PercentSettingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Percentsetting attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Percentsetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PercentSettingAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PercentSettingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PercentSettingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPercentCurrentAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPercentCurrentAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Percentcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Percentcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -574,34 +511,38 @@ suspend fun readPercentCurrentAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Percentcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Percentcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -614,47 +555,41 @@ suspend fun readPercentCurrentAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpeedMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSpeedMaxAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Speedmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -664,123 +599,113 @@ suspend fun readSpeedMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedmax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Speedmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedsetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Speedsetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SpeedSettingAttribute(decodedValue) } - suspend fun writeSpeedSettingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSpeedSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -802,7 +727,7 @@ suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute {val ATTRIBUTE_ID throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSpeedSettingAttribute( @@ -810,99 +735,93 @@ suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SpeedSettingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SpeedSettingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedsetting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Speedsetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SpeedSettingAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SpeedSettingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SpeedSettingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpeedCurrentAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSpeedCurrentAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Speedcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -912,94 +831,88 @@ suspend fun readSpeedCurrentAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedcurrent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Speedcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRockSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRockSupportAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rocksupport attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rocksupport attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1009,118 +922,108 @@ suspend fun readRockSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rocksupport attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rocksupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRockSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRockSettingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rocksetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rocksetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeRockSettingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeRockSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1142,7 +1045,7 @@ suspend fun readRockSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRockSettingAttribute( @@ -1150,94 +1053,88 @@ suspend fun readRockSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rocksetting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rocksetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWindSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWindSupportAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windsupport attribute not found in response" - } + } + + requireNotNull(attributeData) { "Windsupport attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1247,118 +1144,108 @@ suspend fun readWindSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windsupport attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Windsupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWindSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWindSettingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windsetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Windsetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWindSettingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeWindSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1380,7 +1267,7 @@ suspend fun readWindSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWindSettingAttribute( @@ -1388,118 +1275,108 @@ suspend fun readWindSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windsetting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Windsetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAirflowDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAirflowDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Airflowdirection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Airflowdirection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeAirflowDirectionAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeAirflowDirectionAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 11u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1521,7 +1398,7 @@ suspend fun readAirflowDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAirflowDirectionAttribute( @@ -1529,96 +1406,92 @@ suspend fun readAirflowDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Airflowdirection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Airflowdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1628,45 +1501,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1674,49 +1552,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1726,45 +1598,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1772,49 +1649,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1824,45 +1695,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1870,49 +1744,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1922,45 +1790,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1968,44 +1839,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2014,35 +1878,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2054,44 +1920,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2100,34 +1959,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2140,7 +2003,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt index cd6627c787c57a..5597bfd94af98a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt @@ -17,107 +17,80 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class FaultInjectionCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class FaultInjectionCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun failAtFault(type: UByte - ,id: UInt - ,numCallsToSkip: UInt - ,numCallsToFail: UInt - ,takeMutex: Boolean - ,timedInvokeTimeout: Duration? = null) { + suspend fun failAtFault( + type: UByte, + id: UInt, + numCallsToSkip: UInt, + numCallsToFail: UInt, + takeMutex: Boolean, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -136,7 +109,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_NUM_CALLS_TO_FAIL_REQ), numCallsToFail) val TAG_TAKE_MUTEX_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_TAKE_MUTEX_REQ), takeMutex) + tlvWriter.put(ContextSpecificTag(TAG_TAKE_MUTEX_REQ), takeMutex) tlvWriter.endStructure() val request: InvokeRequest = @@ -150,10 +123,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun failRandomlyAtFault(type: UByte - ,id: UInt - ,percentage: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun failRandomlyAtFault( + type: UByte, + id: UInt, + percentage: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -166,7 +141,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ID_REQ), id) val TAG_PERCENTAGE_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_PERCENTAGE_REQ), percentage) + tlvWriter.put(ContextSpecificTag(TAG_PERCENTAGE_REQ), percentage) tlvWriter.endStructure() val request: InvokeRequest = @@ -179,47 +154,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -229,45 +198,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -275,49 +249,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -327,45 +295,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -373,49 +346,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -425,45 +392,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -471,49 +441,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -523,45 +487,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -569,44 +536,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -615,35 +575,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -655,44 +617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -701,34 +656,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -741,7 +700,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt index f36bab66f10935..4fe3dd45c9ccd6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt @@ -17,154 +17,109 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class FixedLabelCluster(private val controller: MatterController, private val endpointId: UShort) {class LabelListAttribute( - val value: List - ) +class FixedLabelCluster(private val controller: MatterController, private val endpointId: UShort) { + class LabelListAttribute(val value: List) sealed class LabelListAttributeSubscriptionState { - data class Success( - val value: List - ) : LabelListAttributeSubscriptionState() - + data class Success(val value: List) : + LabelListAttributeSubscriptionState() + data class Error(val exception: Exception) : LabelListAttributeSubscriptionState() - object SubscriptionEstablished : LabelListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LabelListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readLabelListAttribute(): LabelListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Labellist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Labellist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return LabelListAttribute(decodedValue) } @@ -174,45 +129,48 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LabelListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LabelListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Labellist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Labellist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(LabelListAttributeSubscriptionState.Success(decodedValue)) } @@ -220,49 +178,43 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt emit(LabelListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -272,45 +224,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -318,49 +275,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -370,45 +321,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -416,49 +372,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -468,45 +418,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -514,49 +467,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -566,45 +513,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -612,44 +562,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -658,35 +601,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -698,44 +643,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -744,34 +682,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -784,7 +726,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt index 4987d915eb1c39..35d293bd0a4ca9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt @@ -17,179 +17,130 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class FlowMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: UShort? - ) +class FlowMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: UShort?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: UShort?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: UShort?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -199,96 +150,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -298,96 +243,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -397,95 +338,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -495,96 +432,90 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -594,45 +525,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -640,49 +576,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -692,45 +622,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -738,49 +673,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -790,45 +719,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -836,49 +768,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -888,45 +814,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -934,44 +863,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -980,35 +902,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1020,44 +944,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1066,34 +983,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1106,7 +1027,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt index 472a14b09e3fea..c60f4e6484a856 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class FormaldehydeConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class FormaldehydeConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(FormaldehydeConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger(FormaldehydeConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1067u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt index 6427becbb270e0..f16803780a0253 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt @@ -17,132 +17,102 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralCommissioningCluster(private val controller: MatterController, private val endpointId: UShort) { - class ArmFailSafeResponse( - val errorCode: UByte, - val debugText: String - ) +class GeneralCommissioningCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ArmFailSafeResponse(val errorCode: UByte, val debugText: String) - class SetRegulatoryConfigResponse( - val errorCode: UByte, - val debugText: String - ) + class SetRegulatoryConfigResponse(val errorCode: UByte, val debugText: String) - class CommissioningCompleteResponse( - val errorCode: UByte, - val debugText: String - ) -class BasicCommissioningInfoAttribute( + class CommissioningCompleteResponse(val errorCode: UByte, val debugText: String) + + class BasicCommissioningInfoAttribute( val value: GeneralCommissioningClusterBasicCommissioningInfo ) sealed class BasicCommissioningInfoAttributeSubscriptionState { - data class Success( - val value: GeneralCommissioningClusterBasicCommissioningInfo - ) : BasicCommissioningInfoAttributeSubscriptionState() - + data class Success(val value: GeneralCommissioningClusterBasicCommissioningInfo) : + BasicCommissioningInfoAttributeSubscriptionState() + data class Error(val exception: Exception) : BasicCommissioningInfoAttributeSubscriptionState() - object SubscriptionEstablished : BasicCommissioningInfoAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : BasicCommissioningInfoAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun armFailSafe(expiryLengthSeconds: UShort - ,breadcrumb: ULong - ,timedInvokeTimeout: Duration? = null): ArmFailSafeResponse { + suspend fun armFailSafe( + expiryLengthSeconds: UShort, + breadcrumb: ULong, + timedInvokeTimeout: Duration? = null + ): ArmFailSafeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -152,7 +122,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_EXPIRY_LENGTH_SECONDS_REQ), expiryLengthSeconds) val TAG_BREADCRUMB_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) tlvWriter.endStructure() val request: InvokeRequest = @@ -169,49 +139,43 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ERROR_CODE: Int = 0 var errorCode_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ERROR_CODE)) {errorCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = tlvReader.getString(tag)} - + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { + errorCode_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (errorCode_decoded == null) { - throw IllegalStateException("errorCode not found in TLV") + throw IllegalStateException("errorCode not found in TLV") } - - + if (debugText_decoded == null) { - throw IllegalStateException("debugText not found in TLV") + throw IllegalStateException("debugText not found in TLV") } - tlvReader.exitContainer() - return ArmFailSafeResponse( - errorCode_decoded, - debugText_decoded - ) + return ArmFailSafeResponse(errorCode_decoded, debugText_decoded) } - suspend fun setRegulatoryConfig(newRegulatoryConfig: UByte - ,countryCode: String - ,breadcrumb: ULong - ,timedInvokeTimeout: Duration? = null): SetRegulatoryConfigResponse { + suspend fun setRegulatoryConfig( + newRegulatoryConfig: UByte, + countryCode: String, + breadcrumb: ULong, + timedInvokeTimeout: Duration? = null + ): SetRegulatoryConfigResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -224,7 +188,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_COUNTRY_CODE_REQ), countryCode) val TAG_BREADCRUMB_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) tlvWriter.endStructure() val request: InvokeRequest = @@ -241,50 +205,44 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ERROR_CODE: Int = 0 var errorCode_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ERROR_CODE)) {errorCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = tlvReader.getString(tag)} - + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { + errorCode_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (errorCode_decoded == null) { - throw IllegalStateException("errorCode not found in TLV") + throw IllegalStateException("errorCode not found in TLV") } - - + if (debugText_decoded == null) { - throw IllegalStateException("debugText not found in TLV") + throw IllegalStateException("debugText not found in TLV") } - tlvReader.exitContainer() - return SetRegulatoryConfigResponse( - errorCode_decoded, - debugText_decoded - ) + return SetRegulatoryConfigResponse(errorCode_decoded, debugText_decoded) } - suspend fun commissioningComplete(timedInvokeTimeout: Duration? = null): CommissioningCompleteResponse { + suspend fun commissioningComplete( + timedInvokeTimeout: Duration? = null + ): CommissioningCompleteResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -301,103 +259,84 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ERROR_CODE: Int = 0 var errorCode_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ERROR_CODE)) {errorCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = tlvReader.getString(tag)} - + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { + errorCode_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (errorCode_decoded == null) { - throw IllegalStateException("errorCode not found in TLV") + throw IllegalStateException("errorCode not found in TLV") } - - + if (debugText_decoded == null) { - throw IllegalStateException("debugText not found in TLV") + throw IllegalStateException("debugText not found in TLV") } - tlvReader.exitContainer() - return CommissioningCompleteResponse( - errorCode_decoded, - debugText_decoded - ) + return CommissioningCompleteResponse(errorCode_decoded, debugText_decoded) } -suspend fun readBreadcrumbAttribute(): ULong {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBreadcrumbAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Breadcrumb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Breadcrumb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeBreadcrumbAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeBreadcrumbAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -419,7 +358,7 @@ suspend fun readBreadcrumbAttribute(): ULong {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBreadcrumbAttribute( @@ -427,35 +366,37 @@ suspend fun readBreadcrumbAttribute(): ULong {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Breadcrumb attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Breadcrumb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -467,43 +408,37 @@ suspend fun readBreadcrumbAttribute(): ULong {val ATTRIBUTE_ID: UInt = 0u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Basiccommissioninginfo attribute not found in response" - } + } + + requireNotNull(attributeData) { "Basiccommissioninginfo attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = + GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) return BasicCommissioningInfoAttribute(decodedValue) } @@ -513,39 +448,44 @@ suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BasicCommissioningInfoAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BasicCommissioningInfoAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Basiccommissioninginfo attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Basiccommissioninginfo attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) + val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = + GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) emit(BasicCommissioningInfoAttributeSubscriptionState.Success(decodedValue)) } @@ -553,44 +493,37 @@ suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribu emit(BasicCommissioningInfoAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRegulatoryConfigAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRegulatoryConfigAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Regulatoryconfig attribute not found in response" - } + } + + requireNotNull(attributeData) { "Regulatoryconfig attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -599,34 +532,38 @@ suspend fun readRegulatoryConfigAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Regulatoryconfig attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Regulatoryconfig attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -639,44 +576,37 @@ suspend fun readRegulatoryConfigAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocationCapabilityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLocationCapabilityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Locationcapability attribute not found in response" - } + } + + requireNotNull(attributeData) { "Locationcapability attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -685,34 +615,38 @@ suspend fun readLocationCapabilityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Locationcapability attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Locationcapability attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -725,44 +659,37 @@ suspend fun readLocationCapabilityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportsConcurrentConnectionAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportsConcurrentConnectionAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportsconcurrentconnection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportsconcurrentconnection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -771,34 +698,38 @@ suspend fun readSupportsConcurrentConnectionAttribute(): Boolean {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportsconcurrentconnection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportsconcurrentconnection attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -811,49 +742,43 @@ suspend fun readSupportsConcurrentConnectionAttribute(): Boolean {val ATTRIBUTE_ emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -863,45 +788,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -909,49 +839,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -961,45 +885,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1007,49 +936,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1059,45 +982,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1105,49 +1031,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1157,45 +1077,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1203,44 +1126,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1249,35 +1165,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1289,44 +1207,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1335,34 +1246,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1375,7 +1290,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt index b930fde5339fde..192e15ba65e2d7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt @@ -17,165 +17,125 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) { - class TimeSnapshotResponse( - val systemTimeMs: ULong, - val posixTimeMs: ULong? - ) +class GeneralDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class TimeSnapshotResponse(val systemTimeMs: ULong, val posixTimeMs: ULong?) + + class PayloadTestResponse(val payload: ByteArray) - class PayloadTestResponse( - val payload: ByteArray - ) -class NetworkInterfacesAttribute( - val value: List - ) + class NetworkInterfacesAttribute(val value: List) sealed class NetworkInterfacesAttributeSubscriptionState { - data class Success( - val value: List - ) : NetworkInterfacesAttributeSubscriptionState() - + data class Success(val value: List) : + NetworkInterfacesAttributeSubscriptionState() + data class Error(val exception: Exception) : NetworkInterfacesAttributeSubscriptionState() - object SubscriptionEstablished : NetworkInterfacesAttributeSubscriptionState() - } -class ActiveHardwareFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : NetworkInterfacesAttributeSubscriptionState() + } + + class ActiveHardwareFaultsAttribute(val value: List?) sealed class ActiveHardwareFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveHardwareFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveHardwareFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveHardwareFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveHardwareFaultsAttributeSubscriptionState() - } -class ActiveRadioFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveHardwareFaultsAttributeSubscriptionState() + } + + class ActiveRadioFaultsAttribute(val value: List?) sealed class ActiveRadioFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveRadioFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveRadioFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveRadioFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveRadioFaultsAttributeSubscriptionState() - } -class ActiveNetworkFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveRadioFaultsAttributeSubscriptionState() + } + + class ActiveNetworkFaultsAttribute(val value: List?) sealed class ActiveNetworkFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveNetworkFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveNetworkFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveNetworkFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveNetworkFaultsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ActiveNetworkFaultsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun testEventTrigger(enableKey: ByteArray - ,eventTrigger: ULong - ,timedInvokeTimeout: Duration? = null) { + suspend fun testEventTrigger( + enableKey: ByteArray, + eventTrigger: ULong, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -185,7 +145,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ENABLE_KEY_REQ), enableKey) val TAG_EVENT_TRIGGER_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_EVENT_TRIGGER_REQ), eventTrigger) + tlvWriter.put(ContextSpecificTag(TAG_EVENT_TRIGGER_REQ), eventTrigger) tlvWriter.endStructure() val request: InvokeRequest = @@ -203,7 +163,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -220,57 +180,50 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_SYSTEM_TIME_MS: Int = 0 var systemTimeMs_decoded: ULong? = null - + val TAG_POSIX_TIME_MS: Int = 1 var posixTimeMs_decoded: ULong? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_SYSTEM_TIME_MS)) {systemTimeMs_decoded = tlvReader.getULong(tag)} - - if (tag == ContextSpecificTag(TAG_POSIX_TIME_MS)) {posixTimeMs_decoded = + if (tag == ContextSpecificTag(TAG_SYSTEM_TIME_MS)) { + systemTimeMs_decoded = tlvReader.getULong(tag) + } + + if (tag == ContextSpecificTag(TAG_POSIX_TIME_MS)) { + posixTimeMs_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getULong(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getULong(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (systemTimeMs_decoded == null) { - throw IllegalStateException("systemTimeMs not found in TLV") + throw IllegalStateException("systemTimeMs not found in TLV") } - - - tlvReader.exitContainer() - return TimeSnapshotResponse( - systemTimeMs_decoded, - posixTimeMs_decoded - ) + return TimeSnapshotResponse(systemTimeMs_decoded, posixTimeMs_decoded) } - suspend fun payloadTestRequest(enableKey: ByteArray - ,value: UByte - ,count: UShort - ,timedInvokeTimeout: Duration? = null): PayloadTestResponse { + suspend fun payloadTestRequest( + enableKey: ByteArray, + value: UByte, + count: UShort, + timedInvokeTimeout: Duration? = null + ): PayloadTestResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -283,7 +236,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_VALUE_REQ), value) val TAG_COUNT_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) + tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) tlvWriter.endStructure() val request: InvokeRequest = @@ -300,74 +253,60 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_PAYLOAD: Int = 0 var payload_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_PAYLOAD)) {payload_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_PAYLOAD)) { + payload_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (payload_decoded == null) { - throw IllegalStateException("payload not found in TLV") + throw IllegalStateException("payload not found in TLV") } - tlvReader.exitContainer() - return PayloadTestResponse( - payload_decoded - ) + return PayloadTestResponse(payload_decoded) } -suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networkinterfaces attribute not found in response" - } + } + + requireNotNull(attributeData) { "Networkinterfaces attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return NetworkInterfacesAttribute(decodedValue) } @@ -377,45 +316,50 @@ suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NetworkInterfacesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NetworkInterfacesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networkinterfaces attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Networkinterfaces attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NetworkInterfacesAttributeSubscriptionState.Success(decodedValue)) } @@ -423,44 +367,37 @@ suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute {val AT emit(NetworkInterfacesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRebootCountAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRebootCountAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rebootcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rebootcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -469,35 +406,37 @@ suspend fun readRebootCountAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rebootcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rebootcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -509,47 +448,41 @@ suspend fun readRebootCountAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUpTimeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUpTimeAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uptime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uptime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -559,94 +492,88 @@ suspend fun readUpTimeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uptime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uptime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTotalOperationalHoursAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTotalOperationalHoursAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totaloperationalhours attribute not found in response" - } + } + + requireNotNull(attributeData) { "Totaloperationalhours attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -656,94 +583,90 @@ suspend fun readTotalOperationalHoursAttribute(): UInt? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totaloperationalhours attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Totaloperationalhours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBootReasonAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBootReasonAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bootreason attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bootreason attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -753,100 +676,94 @@ suspend fun readBootReasonAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bootreason attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bootreason attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activehardwarefaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activehardwarefaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveHardwareFaultsAttribute(decodedValue) } @@ -856,106 +773,102 @@ suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveHardwareFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveHardwareFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activehardwarefaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activehardwarefaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveHardwareFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveHardwareFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveHardwareFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeradiofaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activeradiofaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveRadioFaultsAttribute(decodedValue) } @@ -965,106 +878,102 @@ suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveRadioFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveRadioFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeradiofaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activeradiofaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveRadioFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveRadioFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveRadioFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activenetworkfaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activenetworkfaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveNetworkFaultsAttribute(decodedValue) } @@ -1074,97 +983,92 @@ suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveNetworkFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveNetworkFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activenetworkfaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activenetworkfaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveNetworkFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveNetworkFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveNetworkFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTestEventTriggersEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTestEventTriggersEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Testeventtriggersenabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Testeventtriggersenabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -1173,34 +1077,38 @@ suspend fun readTestEventTriggersEnabledAttribute(): Boolean {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Testeventtriggersenabled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Testeventtriggersenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1213,49 +1121,43 @@ suspend fun readTestEventTriggersEnabledAttribute(): Boolean {val ATTRIBUTE_ID: emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1265,45 +1167,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1311,49 +1218,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1363,45 +1264,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1409,49 +1315,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1461,45 +1361,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1507,49 +1410,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1559,45 +1456,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1605,44 +1505,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1651,35 +1544,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1691,44 +1586,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1737,34 +1625,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1777,7 +1669,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt index 975133eb203f79..7d6a660be3afb0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt @@ -17,144 +17,112 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GroupKeyManagementCluster(private val controller: MatterController, private val endpointId: UShort) { - class KeySetReadResponse( - val groupKeySet: GroupKeyManagementClusterGroupKeySetStruct - ) +class GroupKeyManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class KeySetReadResponse(val groupKeySet: GroupKeyManagementClusterGroupKeySetStruct) + + class KeySetReadAllIndicesResponse(val groupKeySetIDs: List) - class KeySetReadAllIndicesResponse( - val groupKeySetIDs: List - ) -class GroupKeyMapAttribute( - val value: List - ) + class GroupKeyMapAttribute(val value: List) sealed class GroupKeyMapAttributeSubscriptionState { - data class Success( - val value: List - ) : GroupKeyMapAttributeSubscriptionState() - + data class Success(val value: List) : + GroupKeyMapAttributeSubscriptionState() + data class Error(val exception: Exception) : GroupKeyMapAttributeSubscriptionState() - object SubscriptionEstablished : GroupKeyMapAttributeSubscriptionState() - } -class GroupTableAttribute( - val value: List - ) + object SubscriptionEstablished : GroupKeyMapAttributeSubscriptionState() + } + + class GroupTableAttribute(val value: List) sealed class GroupTableAttributeSubscriptionState { - data class Success( - val value: List - ) : GroupTableAttributeSubscriptionState() - + data class Success(val value: List) : + GroupTableAttributeSubscriptionState() + data class Error(val exception: Exception) : GroupTableAttributeSubscriptionState() - object SubscriptionEstablished : GroupTableAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GroupTableAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun keySetWrite(groupKeySet: GroupKeyManagementClusterGroupKeySetStruct - ,timedInvokeTimeout: Duration? = null) { + suspend fun keySetWrite( + groupKeySet: GroupKeyManagementClusterGroupKeySetStruct, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_KEY_SET_REQ: Int = 0 - groupKeySet.toTlv(ContextSpecificTag(TAG_GROUP_KEY_SET_REQ), tlvWriter) + groupKeySet.toTlv(ContextSpecificTag(TAG_GROUP_KEY_SET_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -168,15 +136,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun keySetRead(groupKeySetID: UShort - ,timedInvokeTimeout: Duration? = null): KeySetReadResponse { + suspend fun keySetRead( + groupKeySetID: UShort, + timedInvokeTimeout: Duration? = null + ): KeySetReadResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_KEY_SET_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) tlvWriter.endStructure() val request: InvokeRequest = @@ -193,43 +163,34 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_GROUP_KEY_SET: Int = 0 var groupKeySet_decoded: GroupKeyManagementClusterGroupKeySetStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET)) {groupKeySet_decoded = GroupKeyManagementClusterGroupKeySetStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET)) { + groupKeySet_decoded = GroupKeyManagementClusterGroupKeySetStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (groupKeySet_decoded == null) { - throw IllegalStateException("groupKeySet not found in TLV") + throw IllegalStateException("groupKeySet not found in TLV") } - tlvReader.exitContainer() - return KeySetReadResponse( - groupKeySet_decoded - ) + return KeySetReadResponse(groupKeySet_decoded) } - suspend fun keySetRemove(groupKeySetID: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun keySetRemove(groupKeySetID: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_KEY_SET_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) tlvWriter.endStructure() val request: InvokeRequest = @@ -243,11 +204,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun keySetReadAllIndices(timedInvokeTimeout: Duration? = null): KeySetReadAllIndicesResponse { + suspend fun keySetReadAllIndices( + timedInvokeTimeout: Duration? = null + ): KeySetReadAllIndicesResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -264,108 +227,94 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_GROUP_KEY_SET_I_DS: Int = 0 var groupKeySetIDs_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET_I_DS)) {groupKeySetIDs_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - }} - - - else { + if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET_I_DS)) { + groupKeySetIDs_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (groupKeySetIDs_decoded == null) { - throw IllegalStateException("groupKeySetIDs not found in TLV") + throw IllegalStateException("groupKeySetIDs not found in TLV") } - tlvReader.exitContainer() - return KeySetReadAllIndicesResponse( - groupKeySetIDs_decoded - ) + return KeySetReadAllIndicesResponse(groupKeySetIDs_decoded) } -suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Groupkeymap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Groupkeymap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GroupKeyMapAttribute(decodedValue) } suspend fun writeGroupKeyMapAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -387,7 +336,7 @@ suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeGroupKeyMapAttribute( @@ -395,45 +344,48 @@ suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GroupKeyMapAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GroupKeyMapAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Groupkeymap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Groupkeymap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(GroupKeyMapAttributeSubscriptionState.Success(decodedValue)) } @@ -441,49 +393,43 @@ suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute {val ATTRIBUTE_ID: emit(GroupKeyMapAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGroupTableAttribute(): GroupTableAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGroupTableAttribute(): GroupTableAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Grouptable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Grouptable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GroupTableAttribute(decodedValue) } @@ -493,45 +439,48 @@ suspend fun readGroupTableAttribute(): GroupTableAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GroupTableAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GroupTableAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Grouptable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Grouptable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(GroupTableAttributeSubscriptionState.Success(decodedValue)) } @@ -539,44 +488,37 @@ suspend fun readGroupTableAttribute(): GroupTableAttribute {val ATTRIBUTE_ID: UI emit(GroupTableAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxGroupsPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxGroupsPerFabricAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxgroupsperfabric attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxgroupsperfabric attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -585,34 +527,38 @@ suspend fun readMaxGroupsPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxgroupsperfabric attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxgroupsperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -625,44 +571,37 @@ suspend fun readMaxGroupsPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxGroupKeysPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxGroupKeysPerFabricAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxgroupkeysperfabric attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxgroupkeysperfabric attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -671,34 +610,38 @@ suspend fun readMaxGroupKeysPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxgroupkeysperfabric attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxgroupkeysperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -711,49 +654,43 @@ suspend fun readMaxGroupKeysPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -763,45 +700,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -809,49 +751,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -861,45 +797,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -907,49 +848,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -959,45 +894,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1005,49 +943,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1057,45 +989,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1103,44 +1038,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1149,35 +1077,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1189,44 +1119,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1235,34 +1158,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1275,7 +1202,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt index 3236b70b54bf79..ca466afbdd0f61 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt @@ -17,125 +17,83 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class GroupsCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddGroupResponse( - val status: UByte, - val groupID: UShort - ) - - class ViewGroupResponse( - val status: UByte, - val groupID: UShort, - val groupName: String - ) - - class GetGroupMembershipResponse( - val capacity: UByte?, - val groupList: List - ) - - class RemoveGroupResponse( - val status: UByte, - val groupID: UShort - ) -class GeneratedCommandListAttribute( - val value: List - ) + class AddGroupResponse(val status: UByte, val groupID: UShort) + + class ViewGroupResponse(val status: UByte, val groupID: UShort, val groupName: String) + + class GetGroupMembershipResponse(val capacity: UByte?, val groupList: List) + + class RemoveGroupResponse(val status: UByte, val groupID: UShort) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun addGroup(groupID: UShort - ,groupName: String - ,timedInvokeTimeout: Duration? = null): AddGroupResponse { + suspend fun addGroup( + groupID: UShort, + groupName: String, + timedInvokeTimeout: Duration? = null + ): AddGroupResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -145,7 +103,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_GROUP_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) tlvWriter.endStructure() val request: InvokeRequest = @@ -162,54 +120,45 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - tlvReader.exitContainer() - return AddGroupResponse( - status_decoded, - groupID_decoded - ) + return AddGroupResponse(status_decoded, groupID_decoded) } - suspend fun viewGroup(groupID: UShort - ,timedInvokeTimeout: Duration? = null): ViewGroupResponse { + suspend fun viewGroup(groupID: UShort, timedInvokeTimeout: Duration? = null): ViewGroupResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -226,58 +175,52 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_GROUP_NAME: Int = 2 var groupName_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_NAME)) {groupName_decoded = tlvReader.getString(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_NAME)) { + groupName_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (groupName_decoded == null) { - throw IllegalStateException("groupName not found in TLV") + throw IllegalStateException("groupName not found in TLV") } - tlvReader.exitContainer() - return ViewGroupResponse( - status_decoded, - groupID_decoded, - groupName_decoded - ) + return ViewGroupResponse(status_decoded, groupID_decoded, groupName_decoded) } - suspend fun getGroupMembership(groupList: List - ,timedInvokeTimeout: Duration? = null): GetGroupMembershipResponse { + suspend fun getGroupMembership( + groupList: List, + timedInvokeTimeout: Duration? = null + ): GetGroupMembershipResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -285,10 +228,10 @@ class AttributeListAttribute( val TAG_GROUP_LIST_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_GROUP_LIST_REQ)) - for (item in groupList.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in groupList.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -305,68 +248,62 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_CAPACITY: Int = 0 var capacity_decoded: UByte? = null - + val TAG_GROUP_LIST: Int = 1 var groupList_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_CAPACITY)) {capacity_decoded = + if (tag == ContextSpecificTag(TAG_CAPACITY)) { + capacity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_GROUP_LIST)) {groupList_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } } - tlvReader.exitContainer() - }} - - else { + if (tag == ContextSpecificTag(TAG_GROUP_LIST)) { + groupList_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - - - if (groupList_decoded == null) { - throw IllegalStateException("groupList not found in TLV") + throw IllegalStateException("groupList not found in TLV") } - tlvReader.exitContainer() - return GetGroupMembershipResponse( - capacity_decoded, - groupList_decoded - ) + return GetGroupMembershipResponse(capacity_decoded, groupList_decoded) } - suspend fun removeGroup(groupID: UShort - ,timedInvokeTimeout: Duration? = null): RemoveGroupResponse { + suspend fun removeGroup( + groupID: UShort, + timedInvokeTimeout: Duration? = null + ): RemoveGroupResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -383,50 +320,42 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - tlvReader.exitContainer() - return RemoveGroupResponse( - status_decoded, - groupID_decoded - ) + return RemoveGroupResponse(status_decoded, groupID_decoded) } suspend fun removeAllGroups(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -440,9 +369,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addGroupIfIdentifying(groupID: UShort - ,groupName: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun addGroupIfIdentifying( + groupID: UShort, + groupName: String, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -452,7 +383,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_GROUP_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) tlvWriter.endStructure() val request: InvokeRequest = @@ -465,42 +396,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNameSupportAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Namesupport attribute not found in response" - } + } + + requireNotNull(attributeData) { "Namesupport attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -509,35 +433,37 @@ suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Namesupport attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Namesupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -549,49 +475,43 @@ suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -601,45 +521,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -647,49 +572,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -699,45 +618,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -745,49 +669,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -797,45 +715,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -843,49 +764,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -895,45 +810,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -941,44 +859,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -987,35 +898,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1027,44 +940,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1073,34 +979,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1113,7 +1023,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt index 8ca45695cd230c..4d7d42bebb7c47 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt @@ -17,132 +17,104 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class HepaFilterMonitoringCluster(private val controller: MatterController, private val endpointId: UShort) {class LastChangedTimeAttribute( - val value: UInt? - ) +class HepaFilterMonitoringCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LastChangedTimeAttribute(val value: UInt?) sealed class LastChangedTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LastChangedTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : LastChangedTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : LastChangedTimeAttributeSubscriptionState() - object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() - } -class ReplacementProductListAttribute( + object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() + } + + class ReplacementProductListAttribute( val value: List? ) sealed class ReplacementProductListAttributeSubscriptionState { - data class Success( - val value: List? - ) : ReplacementProductListAttributeSubscriptionState() - + data class Success(val value: List?) : + ReplacementProductListAttributeSubscriptionState() + data class Error(val exception: Exception) : ReplacementProductListAttributeSubscriptionState() - object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCondition(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,45 +127,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readConditionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Condition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Condition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -203,94 +169,88 @@ suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Condition attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Condition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDegradationDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Degradationdirection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -300,91 +260,86 @@ suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Degradationdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readChangeIndicationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Changeindication attribute not found in response" - } + } + + requireNotNull(attributeData) { "Changeindication attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -393,34 +348,38 @@ suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Changeindication attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Changeindication attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -433,47 +392,41 @@ suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInPlaceIndicatorAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in response" - } + } + + requireNotNull(attributeData) { "Inplaceindicator attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -483,123 +436,115 @@ suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Inplaceindicator attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastchangedtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastChangedTimeAttribute(decodedValue) } - suspend fun writeLastChangedTimeAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -621,7 +566,7 @@ suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLastChangedTimeAttribute( @@ -629,105 +574,103 @@ suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastChangedTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastChangedTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastchangedtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LastChangedTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LastChangedTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastChangedTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Replacementproductlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ReplacementProductListAttribute(decodedValue) } @@ -737,102 +680,103 @@ suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ReplacementProductListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ReplacementProductListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Replacementproductlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ReplacementProductListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + HepaFilterMonitoringClusterReplacementProductStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ReplacementProductListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ReplacementProductListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -842,45 +786,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -888,49 +837,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -940,45 +883,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -986,49 +934,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1038,45 +980,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1084,49 +1029,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1136,45 +1075,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1182,44 +1124,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1228,35 +1163,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1268,44 +1205,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1314,34 +1244,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1354,7 +1288,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt index ba546ee4142046..771b3cd66f297d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt @@ -17,128 +17,99 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class IcdManagementCluster(private val controller: MatterController, private val endpointId: UShort) { - class RegisterClientResponse( - val ICDCounter: UInt - ) +class IcdManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class RegisterClientResponse(val ICDCounter: UInt) - class StayActiveResponse( - val promisedActiveDuration: UInt - ) -class RegisteredClientsAttribute( + class StayActiveResponse(val promisedActiveDuration: UInt) + + class RegisteredClientsAttribute( val value: List? ) sealed class RegisteredClientsAttributeSubscriptionState { - data class Success( - val value: List? - ) : RegisteredClientsAttributeSubscriptionState() - + data class Success(val value: List?) : + RegisteredClientsAttributeSubscriptionState() + data class Error(val exception: Exception) : RegisteredClientsAttributeSubscriptionState() - object SubscriptionEstablished : RegisteredClientsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : RegisteredClientsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun registerClient(checkInNodeID: ULong - ,monitoredSubject: ULong - ,key: ByteArray - ,verificationKey: ByteArray? - ,clientType: UByte - ,timedInvokeTimeout: Duration? = null): RegisterClientResponse { + suspend fun registerClient( + checkInNodeID: ULong, + monitoredSubject: ULong, + key: ByteArray, + verificationKey: ByteArray?, + clientType: UByte, + timedInvokeTimeout: Duration? = null + ): RegisterClientResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -159,7 +130,7 @@ class AttributeListAttribute( } val TAG_CLIENT_TYPE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_CLIENT_TYPE_REQ), clientType) + tlvWriter.put(ContextSpecificTag(TAG_CLIENT_TYPE_REQ), clientType) tlvWriter.endStructure() val request: InvokeRequest = @@ -176,37 +147,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_I_C_D_COUNTER: Int = 0 var ICDCounter_decoded: UInt? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_I_C_D_COUNTER)) {ICDCounter_decoded = tlvReader.getUInt(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_I_C_D_COUNTER)) { + ICDCounter_decoded = tlvReader.getUInt(tag) + } else { tlvReader.skipElement() } } - - if (ICDCounter_decoded == null) { - throw IllegalStateException("ICDCounter not found in TLV") + throw IllegalStateException("ICDCounter not found in TLV") } - tlvReader.exitContainer() - return RegisterClientResponse( - ICDCounter_decoded - ) + return RegisterClientResponse(ICDCounter_decoded) } - suspend fun unregisterClient(checkInNodeID: ULong - ,verificationKey: ByteArray? - ,timedInvokeTimeout: Duration? = null) { + suspend fun unregisterClient( + checkInNodeID: ULong, + verificationKey: ByteArray?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -218,7 +183,7 @@ class AttributeListAttribute( val TAG_VERIFICATION_KEY_REQ: Int = 1 verificationKey?.let { tlvWriter.put(ContextSpecificTag(TAG_VERIFICATION_KEY_REQ), verificationKey) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -232,15 +197,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stayActiveRequest(stayActiveDuration: UInt - ,timedInvokeTimeout: Duration? = null): StayActiveResponse { + suspend fun stayActiveRequest( + stayActiveDuration: UInt, + timedInvokeTimeout: Duration? = null + ): StayActiveResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_STAY_ACTIVE_DURATION_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_STAY_ACTIVE_DURATION_REQ), stayActiveDuration) + tlvWriter.put(ContextSpecificTag(TAG_STAY_ACTIVE_DURATION_REQ), stayActiveDuration) tlvWriter.endStructure() val request: InvokeRequest = @@ -257,69 +224,54 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_PROMISED_ACTIVE_DURATION: Int = 0 var promisedActiveDuration_decoded: UInt? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_PROMISED_ACTIVE_DURATION)) {promisedActiveDuration_decoded = tlvReader.getUInt(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_PROMISED_ACTIVE_DURATION)) { + promisedActiveDuration_decoded = tlvReader.getUInt(tag) + } else { tlvReader.skipElement() } } - - if (promisedActiveDuration_decoded == null) { - throw IllegalStateException("promisedActiveDuration not found in TLV") + throw IllegalStateException("promisedActiveDuration not found in TLV") } - tlvReader.exitContainer() - return StayActiveResponse( - promisedActiveDuration_decoded - ) + return StayActiveResponse(promisedActiveDuration_decoded) } -suspend fun readIdleModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readIdleModeDurationAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Idlemodeduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Idlemodeduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -328,34 +280,38 @@ suspend fun readIdleModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Idlemodeduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Idlemodeduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -368,44 +324,37 @@ suspend fun readIdleModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveModeDurationAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemodeduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activemodeduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -414,34 +363,38 @@ suspend fun readActiveModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemodeduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activemodeduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -454,44 +407,37 @@ suspend fun readActiveModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveModeThresholdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveModeThresholdAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemodethreshold attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activemodethreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -500,34 +446,38 @@ suspend fun readActiveModeThresholdAttribute(): UShort {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemodethreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activemodethreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -540,53 +490,47 @@ suspend fun readActiveModeThresholdAttribute(): UShort {val ATTRIBUTE_ID: UInt = emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Registeredclients attribute not found in response" - } + } + + requireNotNull(attributeData) { "Registeredclients attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return RegisteredClientsAttribute(decodedValue) } @@ -596,100 +540,101 @@ suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RegisteredClientsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RegisteredClientsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Registeredclients attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Registeredclients attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(RegisteredClientsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + IcdManagementClusterMonitoringRegistrationStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(RegisteredClientsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RegisteredClientsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readICDCounterAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readICDCounterAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Icdcounter attribute not found in response" - } + } + + requireNotNull(attributeData) { "Icdcounter attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -699,94 +644,88 @@ suspend fun readICDCounterAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Icdcounter attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Icdcounter attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClientsSupportedPerFabricAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClientsSupportedPerFabricAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clientssupportedperfabric attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clientssupportedperfabric attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -796,94 +735,90 @@ suspend fun readClientsSupportedPerFabricAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clientssupportedperfabric attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clientssupportedperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUserActiveModeTriggerHintAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUserActiveModeTriggerHintAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Useractivemodetriggerhint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Useractivemodetriggerhint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -893,94 +828,92 @@ suspend fun readUserActiveModeTriggerHintAttribute(): UInt? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Useractivemodetriggerhint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Useractivemodetriggerhint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUserActiveModeTriggerInstructionAttribute(): String? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUserActiveModeTriggerInstructionAttribute(): String? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Useractivemodetriggerinstruction attribute not found in response" + } + + requireNotNull(attributeData) { + "Useractivemodetriggerinstruction attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -990,94 +923,90 @@ suspend fun readUserActiveModeTriggerInstructionAttribute(): String? {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Useractivemodetriggerinstruction attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Useractivemodetriggerinstruction attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperatingModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperatingModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operatingmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operatingmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1087,96 +1016,90 @@ suspend fun readOperatingModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operatingmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Operatingmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1186,45 +1109,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1232,49 +1160,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1284,45 +1206,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1330,49 +1257,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1382,45 +1303,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1428,49 +1352,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1480,45 +1398,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1526,44 +1447,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1572,35 +1486,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1612,44 +1528,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1658,34 +1567,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1698,7 +1611,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt index cdf0dd8d361438..f7ed262f1a73ba 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt @@ -17,110 +17,81 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class IdentifyCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class IdentifyCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun identify(identifyTime: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun identify(identifyTime: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_IDENTIFY_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_IDENTIFY_TIME_REQ), identifyTime) + tlvWriter.put(ContextSpecificTag(TAG_IDENTIFY_TIME_REQ), identifyTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,9 +105,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun triggerEffect(effectIdentifier: UByte - ,effectVariant: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun triggerEffect( + effectIdentifier: UByte, + effectVariant: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -146,7 +119,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_EFFECT_IDENTIFIER_REQ), effectIdentifier) val TAG_EFFECT_VARIANT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) tlvWriter.endStructure() val request: InvokeRequest = @@ -159,65 +132,54 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readIdentifyTimeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readIdentifyTimeAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Identifytime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Identifytime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeIdentifyTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeIdentifyTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -239,7 +201,7 @@ suspend fun readIdentifyTimeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeIdentifyTimeAttribute( @@ -247,35 +209,37 @@ suspend fun readIdentifyTimeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Identifytime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Identifytime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -287,44 +251,37 @@ suspend fun readIdentifyTimeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readIdentifyTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readIdentifyTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Identifytype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Identifytype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -333,35 +290,37 @@ suspend fun readIdentifyTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Identifytype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Identifytype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -373,49 +332,43 @@ suspend fun readIdentifyTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -425,45 +378,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -471,49 +429,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -523,45 +475,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -569,49 +526,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -621,45 +572,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -667,49 +621,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -719,45 +667,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -765,44 +716,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -811,35 +755,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -851,44 +797,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -897,34 +836,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -937,7 +880,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt index cbfb9f08ed8a40..3fbcfa85674aff 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt @@ -17,192 +17,140 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class IlluminanceMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: UShort? - ) +class IlluminanceMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: UShort?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: UShort?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: UShort?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class LightSensorTypeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class LightSensorTypeAttribute(val value: UByte?) sealed class LightSensorTypeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : LightSensorTypeAttributeSubscriptionState() - + data class Success(val value: UByte?) : LightSensorTypeAttributeSubscriptionState() + data class Error(val exception: Exception) : LightSensorTypeAttributeSubscriptionState() - object SubscriptionEstablished : LightSensorTypeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LightSensorTypeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -212,96 +160,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -311,96 +253,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -410,95 +348,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -508,99 +442,93 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lightsensortype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lightsensortype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LightSensorTypeAttribute(decodedValue) } @@ -610,101 +538,97 @@ suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LightSensorTypeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LightSensorTypeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lightsensortype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lightsensortype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LightSensorTypeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LightSensorTypeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LightSensorTypeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -714,45 +638,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -760,49 +689,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -812,45 +735,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -858,49 +786,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -910,45 +832,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -956,49 +881,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1008,45 +927,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1054,44 +976,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1100,35 +1015,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1140,44 +1057,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1186,34 +1096,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1226,7 +1140,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt index 168b0718b0ff16..8e65a58bb20e56 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt @@ -17,114 +17,79 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class KeypadInputCluster(private val controller: MatterController, private val endpointId: UShort) { - class SendKeyResponse( - val status: UByte - ) -class GeneratedCommandListAttribute( - val value: List - ) + class SendKeyResponse(val status: UByte) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun sendKey(keyCode: UByte - ,timedInvokeTimeout: Duration? = null): SendKeyResponse { + suspend fun sendKey(keyCode: UByte, timedInvokeTimeout: Duration? = null): SendKeyResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_KEY_CODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_KEY_CODE_REQ), keyCode) + tlvWriter.put(ContextSpecificTag(TAG_KEY_CODE_REQ), keyCode) tlvWriter.endStructure() val request: InvokeRequest = @@ -141,74 +106,60 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - tlvReader.exitContainer() - return SendKeyResponse( - status_decoded - ) + return SendKeyResponse(status_decoded) } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -218,45 +169,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -264,49 +220,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -316,45 +266,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -362,49 +317,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -414,45 +363,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -460,49 +412,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -512,45 +458,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -558,44 +507,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -604,35 +546,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -644,44 +588,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -690,34 +627,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -730,7 +671,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt index c4800abe53cffd..f782f3ec082767 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt @@ -17,167 +17,125 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryDryerControlsCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedDrynessLevelsAttribute( - val value: List - ) +class LaundryDryerControlsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedDrynessLevelsAttribute(val value: List) sealed class SupportedDrynessLevelsAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedDrynessLevelsAttributeSubscriptionState() - + data class Success(val value: List) : SupportedDrynessLevelsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedDrynessLevelsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedDrynessLevelsAttributeSubscriptionState() - } -class SelectedDrynessLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedDrynessLevelsAttributeSubscriptionState() + } + + class SelectedDrynessLevelAttribute(val value: UByte?) sealed class SelectedDrynessLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : SelectedDrynessLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : SelectedDrynessLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : SelectedDrynessLevelAttributeSubscriptionState() - object SubscriptionEstablished : SelectedDrynessLevelAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SelectedDrynessLevelAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supporteddrynesslevels attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supporteddrynesslevels attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedDrynessLevelsAttribute(decodedValue) } @@ -187,45 +145,50 @@ suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedDrynessLevelsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedDrynessLevelsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supporteddrynesslevels attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supporteddrynesslevels attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(SupportedDrynessLevelsAttributeSubscriptionState.Success(decodedValue)) } @@ -233,72 +196,65 @@ suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribu emit(SupportedDrynessLevelsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selecteddrynesslevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Selecteddrynesslevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SelectedDrynessLevelAttribute(decodedValue) } suspend fun writeSelectedDrynessLevelAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -320,7 +276,7 @@ suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSelectedDrynessLevelAttribute( @@ -328,97 +284,93 @@ suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SelectedDrynessLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SelectedDrynessLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selecteddrynesslevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Selecteddrynesslevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SelectedDrynessLevelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SelectedDrynessLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SelectedDrynessLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -428,45 +380,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -474,49 +431,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -526,45 +477,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -572,49 +528,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -624,45 +574,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -670,49 +623,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -722,45 +669,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -768,44 +718,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -814,35 +757,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -854,44 +799,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -900,34 +838,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -940,7 +882,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt index 2e547ec206a574..42b5ed96fc640a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt @@ -17,184 +17,140 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherControlsCluster(private val controller: MatterController, private val endpointId: UShort) {class SpinSpeedsAttribute( - val value: List? - ) +class LaundryWasherControlsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SpinSpeedsAttribute(val value: List?) sealed class SpinSpeedsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SpinSpeedsAttributeSubscriptionState() - + data class Success(val value: List?) : SpinSpeedsAttributeSubscriptionState() + data class Error(val exception: Exception) : SpinSpeedsAttributeSubscriptionState() - object SubscriptionEstablished : SpinSpeedsAttributeSubscriptionState() - } -class SpinSpeedCurrentAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SpinSpeedsAttributeSubscriptionState() + } + + class SpinSpeedCurrentAttribute(val value: UByte?) sealed class SpinSpeedCurrentAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : SpinSpeedCurrentAttributeSubscriptionState() - + data class Success(val value: UByte?) : SpinSpeedCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : SpinSpeedCurrentAttributeSubscriptionState() - object SubscriptionEstablished : SpinSpeedCurrentAttributeSubscriptionState() - } -class SupportedRinsesAttribute( - val value: List? - ) + object SubscriptionEstablished : SpinSpeedCurrentAttributeSubscriptionState() + } + + class SupportedRinsesAttribute(val value: List?) sealed class SupportedRinsesAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedRinsesAttributeSubscriptionState() - + data class Success(val value: List?) : SupportedRinsesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedRinsesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedRinsesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedRinsesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Spinspeeds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Spinspeeds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SpinSpeedsAttribute(decodedValue) } @@ -204,129 +160,119 @@ suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SpinSpeedsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SpinSpeedsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Spinspeeds attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Spinspeeds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SpinSpeedsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SpinSpeedsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SpinSpeedsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Spinspeedcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Spinspeedcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SpinSpeedCurrentAttribute(decodedValue) } - suspend fun writeSpinSpeedCurrentAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSpinSpeedCurrentAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -348,7 +294,7 @@ suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSpinSpeedCurrentAttribute( @@ -356,123 +302,115 @@ suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SpinSpeedCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SpinSpeedCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Spinspeedcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Spinspeedcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SpinSpeedCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SpinSpeedCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SpinSpeedCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfRinsesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNumberOfRinsesAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofrinses attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofrinses attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeNumberOfRinsesAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNumberOfRinsesAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -494,7 +432,7 @@ suspend fun readNumberOfRinsesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNumberOfRinsesAttribute( @@ -502,100 +440,96 @@ suspend fun readNumberOfRinsesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofrinses attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofrinses attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedrinses attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedrinses attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedRinsesAttribute(decodedValue) } @@ -605,102 +539,98 @@ suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedRinsesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedRinsesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedrinses attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedrinses attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SupportedRinsesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SupportedRinsesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SupportedRinsesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -710,45 +640,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -756,49 +691,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -808,45 +737,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -854,49 +788,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -906,45 +834,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -952,49 +883,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1004,45 +929,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1050,44 +978,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1096,35 +1017,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1136,44 +1059,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1182,34 +1098,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1222,7 +1142,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt index 3094ee32e0a394..39984ca8d45b8c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt @@ -17,154 +17,120 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) +class LaundryWasherModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +147,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +227,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +278,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +317,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +359,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +440,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +448,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +581,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +589,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +687,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +738,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +784,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +835,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +881,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +930,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +976,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1025,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1064,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1106,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1145,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,7 +1189,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt index 293ad3ccf28462..aa67210f9b5551 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt @@ -17,184 +17,143 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LevelControlCluster(private val controller: MatterController, private val endpointId: UShort) {class CurrentLevelAttribute( - val value: UByte? - ) +class LevelControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class CurrentLevelAttribute(val value: UByte?) sealed class CurrentLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentLevelAttributeSubscriptionState() - object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() - } -class OnLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() + } + + class OnLevelAttribute(val value: UByte?) sealed class OnLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : OnLevelAttributeSubscriptionState() - object SubscriptionEstablished : OnLevelAttributeSubscriptionState() - } -class OnTransitionTimeAttribute( - val value: UShort? - ) + object SubscriptionEstablished : OnLevelAttributeSubscriptionState() + } + + class OnTransitionTimeAttribute(val value: UShort?) sealed class OnTransitionTimeAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : OnTransitionTimeAttributeSubscriptionState() - + data class Success(val value: UShort?) : OnTransitionTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnTransitionTimeAttributeSubscriptionState() - object SubscriptionEstablished : OnTransitionTimeAttributeSubscriptionState() - } -class OffTransitionTimeAttribute( - val value: UShort? - ) + object SubscriptionEstablished : OnTransitionTimeAttributeSubscriptionState() + } + + class OffTransitionTimeAttribute(val value: UShort?) sealed class OffTransitionTimeAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : OffTransitionTimeAttributeSubscriptionState() - + data class Success(val value: UShort?) : OffTransitionTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : OffTransitionTimeAttributeSubscriptionState() - object SubscriptionEstablished : OffTransitionTimeAttributeSubscriptionState() - } -class DefaultMoveRateAttribute( - val value: UByte? - ) + object SubscriptionEstablished : OffTransitionTimeAttributeSubscriptionState() + } + + class DefaultMoveRateAttribute(val value: UByte?) sealed class DefaultMoveRateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : DefaultMoveRateAttributeSubscriptionState() - + data class Success(val value: UByte?) : DefaultMoveRateAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultMoveRateAttributeSubscriptionState() - object SubscriptionEstablished : DefaultMoveRateAttributeSubscriptionState() - } -class StartUpCurrentLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : DefaultMoveRateAttributeSubscriptionState() + } + + class StartUpCurrentLevelAttribute(val value: UByte?) sealed class StartUpCurrentLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpCurrentLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpCurrentLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpCurrentLevelAttributeSubscriptionState() - object SubscriptionEstablished : StartUpCurrentLevelAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : StartUpCurrentLevelAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun moveToLevel(level: UByte - ,transitionTime: UShort? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToLevel( + level: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -212,7 +171,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -226,11 +185,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun move(moveMode: UByte - ,rate: UByte? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun move( + moveMode: UByte, + rate: UByte?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -240,15 +201,13 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) val TAG_RATE_REQ: Int = 1 - rate?.let { - tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) - } + rate?.let { tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) } val TAG_OPTIONS_MASK_REQ: Int = 2 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -262,12 +221,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun step(stepMode: UByte - ,stepSize: UByte - ,transitionTime: UShort? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun step( + stepMode: UByte, + stepSize: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -288,7 +249,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -302,9 +263,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stop(optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stop( + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -314,7 +277,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -328,11 +291,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToLevelWithOnOff(level: UByte - ,transitionTime: UShort? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToLevelWithOnOff( + level: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -350,7 +315,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -364,11 +329,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveWithOnOff(moveMode: UByte - ,rate: UByte? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveWithOnOff( + moveMode: UByte, + rate: UByte?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -378,15 +345,13 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) val TAG_RATE_REQ: Int = 1 - rate?.let { - tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) - } + rate?.let { tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) } val TAG_OPTIONS_MASK_REQ: Int = 2 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -400,12 +365,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepWithOnOff(stepMode: UByte - ,stepSize: UByte - ,transitionTime: UShort? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepWithOnOff( + stepMode: UByte, + stepSize: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -426,7 +393,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -440,9 +407,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stopWithOnOff(optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stopWithOnOff( + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -452,7 +421,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -466,15 +435,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToClosestFrequency(frequency: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToClosestFrequency(frequency: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_FREQUENCY_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_FREQUENCY_REQ), frequency) + tlvWriter.put(ContextSpecificTag(TAG_FREQUENCY_REQ), frequency) tlvWriter.endStructure() val request: InvokeRequest = @@ -487,46 +455,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentLevelAttribute(decodedValue) } @@ -536,95 +498,89 @@ suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(CurrentLevelAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(CurrentLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRemainingTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remainingtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -634,94 +590,88 @@ suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingtime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Remainingtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -731,94 +681,88 @@ suspend fun readMinLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -828,94 +772,88 @@ suspend fun readMaxLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -925,94 +863,90 @@ suspend fun readCurrentFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentfrequency attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1022,94 +956,88 @@ suspend fun readMinFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minfrequency attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1119,114 +1047,103 @@ suspend fun readMaxFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxfrequency attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOptionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Options attribute not found in response" - } + } + + requireNotNull(attributeData) { "Options attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeOptionsAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOptionsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 15u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1248,7 +1165,7 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOptionsAttribute( @@ -1256,35 +1173,37 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Options attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Options attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1296,71 +1215,64 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnOffTransitionTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOnOffTransitionTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onofftransitiontime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onofftransitiontime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeOnOffTransitionTimeAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1382,7 +1294,7 @@ suspend fun readOnOffTransitionTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnOffTransitionTimeAttribute( @@ -1390,119 +1302,111 @@ suspend fun readOnOffTransitionTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onofftransitiontime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Onofftransitiontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnLevelAttribute(): OnLevelAttribute {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOnLevelAttribute(): OnLevelAttribute { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnLevelAttribute(decodedValue) } - suspend fun writeOnLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1524,7 +1428,7 @@ suspend fun readOnLevelAttribute(): OnLevelAttribute {val ATTRIBUTE_ID: UInt = 1 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnLevelAttribute( @@ -1532,124 +1436,114 @@ suspend fun readOnLevelAttribute(): OnLevelAttribute {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(OnLevelAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(OnLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ontransitiontime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ontransitiontime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnTransitionTimeAttribute(decodedValue) } - suspend fun writeOnTransitionTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnTransitionTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1671,7 +1565,7 @@ suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnTransitionTimeAttribute( @@ -1679,128 +1573,120 @@ suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnTransitionTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnTransitionTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ontransitiontime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ontransitiontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnTransitionTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnTransitionTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnTransitionTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Offtransitiontime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Offtransitiontime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OffTransitionTimeAttribute(decodedValue) } - suspend fun writeOffTransitionTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOffTransitionTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 19u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1822,7 +1708,7 @@ suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute {val AT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOffTransitionTimeAttribute( @@ -1830,128 +1716,120 @@ suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OffTransitionTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OffTransitionTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Offtransitiontime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Offtransitiontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OffTransitionTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OffTransitionTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OffTransitionTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultmoverate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultmoverate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DefaultMoveRateAttribute(decodedValue) } - suspend fun writeDefaultMoveRateAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultMoveRateAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1973,7 +1851,7 @@ suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultMoveRateAttribute( @@ -1981,128 +1859,120 @@ suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DefaultMoveRateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DefaultMoveRateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultmoverate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultmoverate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DefaultMoveRateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DefaultMoveRateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DefaultMoveRateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute {val ATTRIBUTE_ID: UInt = 16384u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupcurrentlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupcurrentlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpCurrentLevelAttribute(decodedValue) } - suspend fun writeStartUpCurrentLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpCurrentLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16384u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2124,7 +1994,7 @@ suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpCurrentLevelAttribute( @@ -2132,101 +2002,97 @@ suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpCurrentLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpCurrentLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupcurrentlevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Startupcurrentlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpCurrentLevelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpCurrentLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpCurrentLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2236,45 +2102,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2282,49 +2153,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2334,45 +2199,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2380,49 +2250,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2432,45 +2296,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2478,49 +2345,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2530,45 +2391,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2576,44 +2440,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2622,35 +2479,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2662,44 +2521,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2708,34 +2560,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2748,7 +2604,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt index d2c92eb1b5c1f9..3eb0f7f602ddea 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt @@ -17,172 +17,129 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LocalizationConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedLocalesAttribute( - val value: List - ) +class LocalizationConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedLocalesAttribute(val value: List) sealed class SupportedLocalesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedLocalesAttributeSubscriptionState() - + data class Success(val value: List) : SupportedLocalesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedLocalesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedLocalesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedLocalesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readActiveLocaleAttribute(): String {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readActiveLocaleAttribute(): String { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activelocale attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activelocale attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeActiveLocaleAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeActiveLocaleAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -204,7 +161,7 @@ suspend fun readActiveLocaleAttribute(): String {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeActiveLocaleAttribute( @@ -212,35 +169,37 @@ suspend fun readActiveLocaleAttribute(): String {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activelocale attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activelocale attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -252,49 +211,43 @@ suspend fun readActiveLocaleAttribute(): String {val ATTRIBUTE_ID: UInt = 0u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedlocales attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedlocales attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedLocalesAttribute(decodedValue) } @@ -304,45 +257,50 @@ suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedLocalesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedLocalesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedlocales attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedlocales attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(SupportedLocalesAttributeSubscriptionState.Success(decodedValue)) } @@ -350,49 +308,43 @@ suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute {val ATTR emit(SupportedLocalesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -402,45 +354,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -448,49 +405,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -500,45 +451,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -546,49 +502,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -598,45 +548,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -644,49 +597,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -696,45 +643,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -742,44 +692,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -788,35 +731,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -828,44 +773,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -874,34 +812,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -914,7 +856,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt index 93f537837ccd34..b0ca32ffc850b8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt @@ -17,106 +17,73 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LowPowerCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class LowPowerCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun sleep(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -129,47 +96,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -179,45 +140,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -225,49 +191,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -277,45 +237,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -323,49 +288,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -375,45 +334,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -421,49 +383,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -473,45 +429,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -519,44 +478,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -565,35 +517,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -605,44 +559,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -651,34 +598,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -691,7 +642,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt index d26de7c78f7c10..96e656cd0a7bc9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt @@ -17,123 +17,89 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaInputCluster(private val controller: MatterController, private val endpointId: UShort) {class InputListAttribute( - val value: List - ) +class MediaInputCluster(private val controller: MatterController, private val endpointId: UShort) { + class InputListAttribute(val value: List) sealed class InputListAttributeSubscriptionState { - data class Success( - val value: List - ) : InputListAttributeSubscriptionState() - + data class Success(val value: List) : + InputListAttributeSubscriptionState() + data class Error(val exception: Exception) : InputListAttributeSubscriptionState() - object SubscriptionEstablished : InputListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : InputListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun selectInput(index: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun selectInput(index: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) tlvWriter.endStructure() val request: InvokeRequest = @@ -151,7 +117,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -169,7 +135,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -183,9 +149,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun renameInput(index: UByte - ,name: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun renameInput(index: UByte, name: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -195,7 +159,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) val TAG_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) + tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) tlvWriter.endStructure() val request: InvokeRequest = @@ -208,47 +172,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readInputListAttribute(): InputListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInputListAttribute(): InputListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inputlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Inputlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return InputListAttribute(decodedValue) } @@ -258,45 +216,48 @@ suspend fun readInputListAttribute(): InputListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(InputListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + InputListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inputlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Inputlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(InputListAttributeSubscriptionState.Success(decodedValue)) } @@ -304,44 +265,37 @@ suspend fun readInputListAttribute(): InputListAttribute {val ATTRIBUTE_ID: UInt emit(InputListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentInputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentInputAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentinput attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentinput attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -350,35 +304,37 @@ suspend fun readCurrentInputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentinput attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentinput attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -390,49 +346,43 @@ suspend fun readCurrentInputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -442,45 +392,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -488,49 +443,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -540,45 +489,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -586,49 +540,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -638,45 +586,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -684,49 +635,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -736,45 +681,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -782,44 +730,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -828,35 +769,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -868,44 +811,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -914,34 +850,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -954,7 +894,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt index 189d95aadc2ba5..12b2afd339765b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt @@ -17,228 +17,176 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackCluster(private val controller: MatterController, private val endpointId: UShort) { - class PlaybackResponse( - val status: UByte, - val data: String? - ) -class StartTimeAttribute( - val value: ULong? - ) +class MediaPlaybackCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class PlaybackResponse(val status: UByte, val data: String?) + + class StartTimeAttribute(val value: ULong?) sealed class StartTimeAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : StartTimeAttributeSubscriptionState() - + data class Success(val value: ULong?) : StartTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartTimeAttributeSubscriptionState() - object SubscriptionEstablished : StartTimeAttributeSubscriptionState() - } -class DurationAttribute( - val value: ULong? - ) + object SubscriptionEstablished : StartTimeAttributeSubscriptionState() + } + + class DurationAttribute(val value: ULong?) sealed class DurationAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : DurationAttributeSubscriptionState() - + data class Success(val value: ULong?) : DurationAttributeSubscriptionState() + data class Error(val exception: Exception) : DurationAttributeSubscriptionState() - object SubscriptionEstablished : DurationAttributeSubscriptionState() - } -class SampledPositionAttribute( - val value: MediaPlaybackClusterPlaybackPositionStruct? - ) + object SubscriptionEstablished : DurationAttributeSubscriptionState() + } + + class SampledPositionAttribute(val value: MediaPlaybackClusterPlaybackPositionStruct?) sealed class SampledPositionAttributeSubscriptionState { - data class Success( - val value: MediaPlaybackClusterPlaybackPositionStruct? - ) : SampledPositionAttributeSubscriptionState() - + data class Success(val value: MediaPlaybackClusterPlaybackPositionStruct?) : + SampledPositionAttributeSubscriptionState() + data class Error(val exception: Exception) : SampledPositionAttributeSubscriptionState() - object SubscriptionEstablished : SampledPositionAttributeSubscriptionState() - } -class SeekRangeEndAttribute( - val value: ULong? - ) + object SubscriptionEstablished : SampledPositionAttributeSubscriptionState() + } + + class SeekRangeEndAttribute(val value: ULong?) sealed class SeekRangeEndAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : SeekRangeEndAttributeSubscriptionState() - + data class Success(val value: ULong?) : SeekRangeEndAttributeSubscriptionState() + data class Error(val exception: Exception) : SeekRangeEndAttributeSubscriptionState() - object SubscriptionEstablished : SeekRangeEndAttributeSubscriptionState() - } -class SeekRangeStartAttribute( - val value: ULong? - ) + object SubscriptionEstablished : SeekRangeEndAttributeSubscriptionState() + } + + class SeekRangeStartAttribute(val value: ULong?) sealed class SeekRangeStartAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : SeekRangeStartAttributeSubscriptionState() - + data class Success(val value: ULong?) : SeekRangeStartAttributeSubscriptionState() + data class Error(val exception: Exception) : SeekRangeStartAttributeSubscriptionState() - object SubscriptionEstablished : SeekRangeStartAttributeSubscriptionState() - } -class ActiveAudioTrackAttribute( - val value: MediaPlaybackClusterTrackStruct? - ) + object SubscriptionEstablished : SeekRangeStartAttributeSubscriptionState() + } + + class ActiveAudioTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) sealed class ActiveAudioTrackAttributeSubscriptionState { - data class Success( - val value: MediaPlaybackClusterTrackStruct? - ) : ActiveAudioTrackAttributeSubscriptionState() - + data class Success(val value: MediaPlaybackClusterTrackStruct?) : + ActiveAudioTrackAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveAudioTrackAttributeSubscriptionState() - object SubscriptionEstablished : ActiveAudioTrackAttributeSubscriptionState() - } -class AvailableAudioTracksAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveAudioTrackAttributeSubscriptionState() + } + + class AvailableAudioTracksAttribute(val value: List?) sealed class AvailableAudioTracksAttributeSubscriptionState { - data class Success( - val value: List? - ) : AvailableAudioTracksAttributeSubscriptionState() - + data class Success(val value: List?) : + AvailableAudioTracksAttributeSubscriptionState() + data class Error(val exception: Exception) : AvailableAudioTracksAttributeSubscriptionState() - object SubscriptionEstablished : AvailableAudioTracksAttributeSubscriptionState() - } -class ActiveTextTrackAttribute( - val value: MediaPlaybackClusterTrackStruct? - ) + object SubscriptionEstablished : AvailableAudioTracksAttributeSubscriptionState() + } + + class ActiveTextTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) sealed class ActiveTextTrackAttributeSubscriptionState { - data class Success( - val value: MediaPlaybackClusterTrackStruct? - ) : ActiveTextTrackAttributeSubscriptionState() - + data class Success(val value: MediaPlaybackClusterTrackStruct?) : + ActiveTextTrackAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveTextTrackAttributeSubscriptionState() - object SubscriptionEstablished : ActiveTextTrackAttributeSubscriptionState() - } -class AvailableTextTracksAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveTextTrackAttributeSubscriptionState() + } + + class AvailableTextTracksAttribute(val value: List?) sealed class AvailableTextTracksAttributeSubscriptionState { - data class Success( - val value: List? - ) : AvailableTextTracksAttributeSubscriptionState() - + data class Success(val value: List?) : + AvailableTextTracksAttributeSubscriptionState() + data class Error(val exception: Exception) : AvailableTextTracksAttributeSubscriptionState() - object SubscriptionEstablished : AvailableTextTracksAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AvailableTextTracksAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun play(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -255,57 +203,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun pause(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -322,57 +261,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun stop(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -389,57 +319,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun startOver(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -456,57 +377,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun previous(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -523,57 +435,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun next(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -590,54 +493,47 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun rewind(audioAdvanceUnmuted: Boolean? - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun rewind( + audioAdvanceUnmuted: Boolean?, + timedInvokeTimeout: Duration? = null + ): PlaybackResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -646,7 +542,7 @@ class AttributeListAttribute( val TAG_AUDIO_ADVANCE_UNMUTED_REQ: Int = 0 audioAdvanceUnmuted?.let { tlvWriter.put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED_REQ), audioAdvanceUnmuted) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -663,54 +559,47 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun fastForward(audioAdvanceUnmuted: Boolean? - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun fastForward( + audioAdvanceUnmuted: Boolean?, + timedInvokeTimeout: Duration? = null + ): PlaybackResponse { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -719,7 +608,7 @@ class AttributeListAttribute( val TAG_AUDIO_ADVANCE_UNMUTED_REQ: Int = 0 audioAdvanceUnmuted?.let { tlvWriter.put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED_REQ), audioAdvanceUnmuted) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -736,61 +625,57 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun skipForward(deltaPositionMilliseconds: ULong - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun skipForward( + deltaPositionMilliseconds: ULong, + timedInvokeTimeout: Duration? = null + ): PlaybackResponse { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DELTA_POSITION_MILLISECONDS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), deltaPositionMilliseconds) + tlvWriter.put( + ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), + deltaPositionMilliseconds + ) tlvWriter.endStructure() val request: InvokeRequest = @@ -807,61 +692,57 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun skipBackward(deltaPositionMilliseconds: ULong - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun skipBackward( + deltaPositionMilliseconds: ULong, + timedInvokeTimeout: Duration? = null + ): PlaybackResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DELTA_POSITION_MILLISECONDS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), deltaPositionMilliseconds) + tlvWriter.put( + ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), + deltaPositionMilliseconds + ) tlvWriter.endStructure() val request: InvokeRequest = @@ -878,61 +759,51 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun seek(position: ULong - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun seek(position: ULong, timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_POSITION_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_POSITION_REQ), position) + tlvWriter.put(ContextSpecificTag(TAG_POSITION_REQ), position) tlvWriter.endStructure() val request: InvokeRequest = @@ -949,55 +820,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun activateAudioTrack(trackID: String - ,audioOutputIndex: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun activateAudioTrack( + trackID: String, + audioOutputIndex: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 12u val tlvWriter = TlvWriter() @@ -1007,7 +871,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) val TAG_AUDIO_OUTPUT_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX_REQ), audioOutputIndex) + tlvWriter.put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX_REQ), audioOutputIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -1021,15 +885,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun activateTextTrack(trackID: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun activateTextTrack(trackID: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 13u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TRACK_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) + tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) tlvWriter.endStructure() val request: InvokeRequest = @@ -1047,7 +910,7 @@ class AttributeListAttribute( val commandId: UInt = 14u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -1060,42 +923,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCurrentStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1104,35 +960,37 @@ suspend fun readCurrentStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1144,52 +1002,46 @@ suspend fun readCurrentStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartTimeAttribute(): StartTimeAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStartTimeAttribute(): StartTimeAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Starttime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Starttime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartTimeAttribute(decodedValue) } @@ -1199,104 +1051,98 @@ suspend fun readStartTimeAttribute(): StartTimeAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Starttime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Starttime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDurationAttribute(): DurationAttribute {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDurationAttribute(): DurationAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Duration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Duration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DurationAttribute(decodedValue) } @@ -1306,104 +1152,98 @@ suspend fun readDurationAttribute(): DurationAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Duration attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Duration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DurationAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSampledPositionAttribute(): SampledPositionAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSampledPositionAttribute(): SampledPositionAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sampledposition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sampledposition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SampledPositionAttribute(decodedValue) } @@ -1413,99 +1253,95 @@ suspend fun readSampledPositionAttribute(): SampledPositionAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SampledPositionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SampledPositionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sampledposition attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sampledposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SampledPositionAttributeSubscriptionState.Success(it)) - } - + val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SampledPositionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SampledPositionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPlaybackSpeedAttribute(): Float? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPlaybackSpeedAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Playbackspeed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Playbackspeed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -1515,99 +1351,93 @@ suspend fun readPlaybackSpeedAttribute(): Float? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Playbackspeed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Playbackspeed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Seekrangeend attribute not found in response" - } + } + + requireNotNull(attributeData) { "Seekrangeend attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SeekRangeEndAttribute(decodedValue) } @@ -1617,104 +1447,98 @@ suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SeekRangeEndAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SeekRangeEndAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Seekrangeend attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Seekrangeend attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SeekRangeEndAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SeekRangeEndAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SeekRangeEndAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Seekrangestart attribute not found in response" - } + } + + requireNotNull(attributeData) { "Seekrangestart attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SeekRangeStartAttribute(decodedValue) } @@ -1724,104 +1548,100 @@ suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SeekRangeStartAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SeekRangeStartAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Seekrangestart attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Seekrangestart attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SeekRangeStartAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SeekRangeStartAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SeekRangeStartAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeaudiotrack attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activeaudiotrack attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveAudioTrackAttribute(decodedValue) } @@ -1831,110 +1651,106 @@ suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveAudioTrackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveAudioTrackAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeaudiotrack attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activeaudiotrack attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveAudioTrackAttributeSubscriptionState.Success(it)) - } - + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveAudioTrackAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveAudioTrackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availableaudiotracks attribute not found in response" - } + } + + requireNotNull(attributeData) { "Availableaudiotracks attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return AvailableAudioTracksAttribute(decodedValue) } @@ -1944,110 +1760,106 @@ suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AvailableAudioTracksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AvailableAudioTracksAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availableaudiotracks attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Availableaudiotracks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AvailableAudioTracksAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AvailableAudioTracksAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AvailableAudioTracksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetexttrack attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activetexttrack attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveTextTrackAttribute(decodedValue) } @@ -2057,110 +1869,106 @@ suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveTextTrackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveTextTrackAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetexttrack attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activetexttrack attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveTextTrackAttributeSubscriptionState.Success(it)) - } - + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveTextTrackAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveTextTrackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availabletexttracks attribute not found in response" - } + } + + requireNotNull(attributeData) { "Availabletexttracks attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return AvailableTextTracksAttribute(decodedValue) } @@ -2170,107 +1978,103 @@ suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AvailableTextTracksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AvailableTextTracksAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availabletexttracks attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Availabletexttracks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AvailableTextTracksAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AvailableTextTracksAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AvailableTextTracksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2280,45 +2084,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2326,49 +2135,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2378,45 +2181,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2424,49 +2232,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2476,45 +2278,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2522,49 +2327,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2574,45 +2373,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2620,44 +2422,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2666,35 +2461,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2706,44 +2503,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2752,34 +2542,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2792,7 +2586,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MessagesCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MessagesCluster.kt index 00d86e861cb361..3e3fcd8f02d2f8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MessagesCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MessagesCluster.kt @@ -17,135 +17,100 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MessagesCluster(private val controller: MatterController, private val endpointId: UShort) {class MessagesAttribute( - val value: List - ) +class MessagesCluster(private val controller: MatterController, private val endpointId: UShort) { + class MessagesAttribute(val value: List) sealed class MessagesAttributeSubscriptionState { - data class Success( - val value: List - ) : MessagesAttributeSubscriptionState() - + data class Success(val value: List) : + MessagesAttributeSubscriptionState() + data class Error(val exception: Exception) : MessagesAttributeSubscriptionState() - object SubscriptionEstablished : MessagesAttributeSubscriptionState() - } -class ActiveMessageIDsAttribute( - val value: List - ) + object SubscriptionEstablished : MessagesAttributeSubscriptionState() + } + + class ActiveMessageIDsAttribute(val value: List) sealed class ActiveMessageIDsAttributeSubscriptionState { - data class Success( - val value: List - ) : ActiveMessageIDsAttributeSubscriptionState() - + data class Success(val value: List) : ActiveMessageIDsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveMessageIDsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveMessageIDsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ActiveMessageIDsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun presentMessagesRequest(messageID: ByteArray - ,priority: UByte - ,messageControl: UByte - ,startTime: UInt? - ,duration: ULong? - ,messageText: String - ,responses: List? - ,timedInvokeTimeout: Duration? = null) { + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun presentMessagesRequest( + messageID: ByteArray, + priority: UByte, + messageControl: UByte, + startTime: UInt?, + duration: ULong?, + messageText: String, + responses: List?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -161,14 +126,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MESSAGE_CONTROL_REQ), messageControl) val TAG_START_TIME_REQ: Int = 3 - startTime?.let { - tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) - } + startTime?.let { tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) } val TAG_DURATION_REQ: Int = 4 - duration?.let { - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) - } + duration?.let { tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) } val TAG_MESSAGE_TEXT_REQ: Int = 5 tlvWriter.put(ContextSpecificTag(TAG_MESSAGE_TEXT_REQ), messageText) @@ -180,7 +141,7 @@ class AttributeListAttribute( item.toTlv(AnonymousTag, tlvWriter) } tlvWriter.endArray() - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -194,8 +155,10 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun cancelMessagesRequest(messageIDs: List - ,timedInvokeTimeout: Duration? = null) { + suspend fun cancelMessagesRequest( + messageIDs: List, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -203,10 +166,10 @@ class AttributeListAttribute( val TAG_MESSAGE_I_DS_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_MESSAGE_I_DS_REQ)) - for (item in messageIDs.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in messageIDs.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -219,47 +182,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readMessagesAttribute(): MessagesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMessagesAttribute(): MessagesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Messages attribute not found in response" - } + } + + requireNotNull(attributeData) { "Messages attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MessagesClusterMessageStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MessagesClusterMessageStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return MessagesAttribute(decodedValue) } @@ -269,45 +226,48 @@ suspend fun readMessagesAttribute(): MessagesAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MessagesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MessagesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Messages attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Messages attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MessagesClusterMessageStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MessagesClusterMessageStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(MessagesAttributeSubscriptionState.Success(decodedValue)) } @@ -315,49 +275,43 @@ suspend fun readMessagesAttribute(): MessagesAttribute {val ATTRIBUTE_ID: UInt = emit(MessagesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveMessageIDsAttribute(): ActiveMessageIDsAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveMessageIDsAttribute(): ActiveMessageIDsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemessageids attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activemessageids attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ActiveMessageIDsAttribute(decodedValue) } @@ -367,45 +321,50 @@ suspend fun readActiveMessageIDsAttribute(): ActiveMessageIDsAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveMessageIDsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveMessageIDsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemessageids attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activemessageids attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ActiveMessageIDsAttributeSubscriptionState.Success(decodedValue)) } @@ -413,49 +372,43 @@ suspend fun readActiveMessageIDsAttribute(): ActiveMessageIDsAttribute {val ATTR emit(ActiveMessageIDsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -465,45 +418,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -511,49 +469,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -563,45 +515,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -609,49 +566,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -661,45 +612,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -707,49 +661,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -759,45 +707,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -805,44 +756,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -851,35 +795,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -891,44 +837,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -937,34 +876,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -977,7 +920,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt index 08a1b816898255..2548f9fdc3e725 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt @@ -17,139 +17,104 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MicrowaveOvenControlCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedWattsAttribute( - val value: List? - ) +class MicrowaveOvenControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedWattsAttribute(val value: List?) sealed class SupportedWattsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedWattsAttributeSubscriptionState() - + data class Success(val value: List?) : SupportedWattsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedWattsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedWattsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedWattsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setCookingParameters(cookMode: UByte? - ,cookTime: UInt? - ,powerSetting: UByte? - ,wattSettingIndex: UByte? - ,startAfterSetting: Boolean? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setCookingParameters( + cookMode: UByte?, + cookTime: UInt?, + powerSetting: UByte?, + wattSettingIndex: UByte?, + startAfterSetting: Boolean?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_COOK_MODE_REQ: Int = 0 - cookMode?.let { - tlvWriter.put(ContextSpecificTag(TAG_COOK_MODE_REQ), cookMode) - } + cookMode?.let { tlvWriter.put(ContextSpecificTag(TAG_COOK_MODE_REQ), cookMode) } val TAG_COOK_TIME_REQ: Int = 1 - cookTime?.let { - tlvWriter.put(ContextSpecificTag(TAG_COOK_TIME_REQ), cookTime) - } + cookTime?.let { tlvWriter.put(ContextSpecificTag(TAG_COOK_TIME_REQ), cookTime) } val TAG_POWER_SETTING_REQ: Int = 2 - powerSetting?.let { - tlvWriter.put(ContextSpecificTag(TAG_POWER_SETTING_REQ), powerSetting) - } + powerSetting?.let { tlvWriter.put(ContextSpecificTag(TAG_POWER_SETTING_REQ), powerSetting) } val TAG_WATT_SETTING_INDEX_REQ: Int = 3 wattSettingIndex?.let { @@ -159,7 +124,7 @@ class AttributeListAttribute( val TAG_START_AFTER_SETTING_REQ: Int = 4 startAfterSetting?.let { tlvWriter.put(ContextSpecificTag(TAG_START_AFTER_SETTING_REQ), startAfterSetting) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -173,15 +138,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addMoreTime(timeToAdd: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun addMoreTime(timeToAdd: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TIME_TO_ADD_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TIME_TO_ADD_REQ), timeToAdd) + tlvWriter.put(ContextSpecificTag(TAG_TIME_TO_ADD_REQ), timeToAdd) tlvWriter.endStructure() val request: InvokeRequest = @@ -194,42 +158,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCookTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cooktime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Cooktime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -238,35 +195,37 @@ suspend fun readCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cooktime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Cooktime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -278,44 +237,37 @@ suspend fun readCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxCookTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcooktime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxcooktime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -324,35 +276,37 @@ suspend fun readMaxCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcooktime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxcooktime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -364,47 +318,41 @@ suspend fun readMaxCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPowerSettingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powersetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powersetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -414,94 +362,88 @@ suspend fun readPowerSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powersetting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powersetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinPowerAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -511,94 +453,88 @@ suspend fun readMinPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxPowerAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -608,94 +544,88 @@ suspend fun readMaxPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPowerStepAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerstep attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerstep attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -705,100 +635,94 @@ suspend fun readPowerStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerstep attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powerstep attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedWattsAttribute(): SupportedWattsAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedWattsAttribute(): SupportedWattsAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedwatts attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedwatts attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedWattsAttribute(decodedValue) } @@ -808,100 +732,96 @@ suspend fun readSupportedWattsAttribute(): SupportedWattsAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedWattsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedWattsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedwatts attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedwatts attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SupportedWattsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SupportedWattsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SupportedWattsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSelectedWattIndexAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSelectedWattIndexAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedwattindex attribute not found in response" - } + } + + requireNotNull(attributeData) { "Selectedwattindex attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -911,94 +831,90 @@ suspend fun readSelectedWattIndexAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedwattindex attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Selectedwattindex attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWattRatingAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWattRatingAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wattrating attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wattrating attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1008,96 +924,90 @@ suspend fun readWattRatingAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wattrating attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Wattrating attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1107,45 +1017,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1153,49 +1068,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1205,45 +1114,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1251,49 +1165,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1303,45 +1211,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1349,49 +1260,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1401,45 +1306,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1447,44 +1355,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1493,35 +1394,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1533,44 +1436,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1579,34 +1475,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1619,7 +1519,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt index 70c0c2f0b02c69..8362dcb4500717 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt @@ -17,154 +17,113 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class MicrowaveOvenModeCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedModesAttribute( - val value: List - ) +class MicrowaveOvenModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -174,45 +133,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -220,44 +184,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -266,35 +223,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -306,49 +265,43 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -358,45 +311,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -404,49 +362,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -456,45 +408,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -502,49 +459,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -554,45 +505,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -600,49 +554,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -652,45 +600,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -698,44 +649,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -744,35 +688,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -784,44 +730,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -830,34 +769,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -870,7 +813,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt index e07ee80f76b046..0119244a4e3865 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt @@ -17,162 +17,123 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ModeSelectCluster(private val controller: MatterController, private val endpointId: UShort) {class StandardNamespaceAttribute( - val value: UShort? - ) +class ModeSelectCluster(private val controller: MatterController, private val endpointId: UShort) { + class StandardNamespaceAttribute(val value: UShort?) sealed class StandardNamespaceAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : StandardNamespaceAttributeSubscriptionState() - + data class Success(val value: UShort?) : StandardNamespaceAttributeSubscriptionState() + data class Error(val exception: Exception) : StandardNamespaceAttributeSubscriptionState() - object SubscriptionEstablished : StandardNamespaceAttributeSubscriptionState() - } -class SupportedModesAttribute( - val value: List - ) + object SubscriptionEstablished : StandardNamespaceAttributeSubscriptionState() + } + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun changeToMode(newMode: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -185,42 +146,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDescriptionAttribute(): String { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in response" - } + } + + requireNotNull(attributeData) { "Description attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -229,35 +183,37 @@ suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Description attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -269,48 +225,42 @@ suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 0u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Standardnamespace attribute not found in response" - } + } + + requireNotNull(attributeData) { "Standardnamespace attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return StandardNamespaceAttribute(decodedValue) } @@ -320,97 +270,93 @@ suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StandardNamespaceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StandardNamespaceAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Standardnamespace attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Standardnamespace attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StandardNamespaceAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StandardNamespaceAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StandardNamespaceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -420,45 +366,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -466,44 +417,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -512,35 +456,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -552,76 +498,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -643,7 +579,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -651,128 +587,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -794,7 +720,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -802,101 +728,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -906,45 +826,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -952,49 +877,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1004,45 +923,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1050,49 +974,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1102,45 +1020,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1148,49 +1069,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1200,45 +1115,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1246,44 +1164,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1292,35 +1203,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1332,44 +1245,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1378,34 +1284,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1418,7 +1328,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt index 87f6e08bbd6d68..c7568cff62a71f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt @@ -17,209 +17,166 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class NetworkCommissioningCluster(private val controller: MatterController, private val endpointId: UShort) { +class NetworkCommissioningCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class ScanNetworksResponse( - val networkingStatus: UByte, - val debugText: String?, - val wiFiScanResults: List?, + val networkingStatus: UByte, + val debugText: String?, + val wiFiScanResults: List?, val threadScanResults: List? ) class NetworkConfigResponse( - val networkingStatus: UByte, - val debugText: String?, - val networkIndex: UByte?, - val clientIdentity: ByteArray?, + val networkingStatus: UByte, + val debugText: String?, + val networkIndex: UByte?, + val clientIdentity: ByteArray?, val possessionSignature: ByteArray? ) class ConnectNetworkResponse( - val networkingStatus: UByte, - val debugText: String?, + val networkingStatus: UByte, + val debugText: String?, val errorValue: Int? ) - class QueryIdentityResponse( - val identity: ByteArray, - val possessionSignature: ByteArray? - ) -class NetworksAttribute( - val value: List - ) + class QueryIdentityResponse(val identity: ByteArray, val possessionSignature: ByteArray?) + + class NetworksAttribute(val value: List) sealed class NetworksAttributeSubscriptionState { - data class Success( - val value: List - ) : NetworksAttributeSubscriptionState() - + data class Success(val value: List) : + NetworksAttributeSubscriptionState() + data class Error(val exception: Exception) : NetworksAttributeSubscriptionState() - object SubscriptionEstablished : NetworksAttributeSubscriptionState() - } -class LastNetworkingStatusAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NetworksAttributeSubscriptionState() + } + + class LastNetworkingStatusAttribute(val value: UByte?) sealed class LastNetworkingStatusAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : LastNetworkingStatusAttributeSubscriptionState() - + data class Success(val value: UByte?) : LastNetworkingStatusAttributeSubscriptionState() + data class Error(val exception: Exception) : LastNetworkingStatusAttributeSubscriptionState() - object SubscriptionEstablished : LastNetworkingStatusAttributeSubscriptionState() - } -class LastNetworkIDAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : LastNetworkingStatusAttributeSubscriptionState() + } + + class LastNetworkIDAttribute(val value: ByteArray?) sealed class LastNetworkIDAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : LastNetworkIDAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : LastNetworkIDAttributeSubscriptionState() + data class Error(val exception: Exception) : LastNetworkIDAttributeSubscriptionState() - object SubscriptionEstablished : LastNetworkIDAttributeSubscriptionState() - } -class LastConnectErrorValueAttribute( - val value: Int? - ) + object SubscriptionEstablished : LastNetworkIDAttributeSubscriptionState() + } + + class LastConnectErrorValueAttribute(val value: Int?) sealed class LastConnectErrorValueAttributeSubscriptionState { - data class Success( - val value: Int? - ) : LastConnectErrorValueAttributeSubscriptionState() - + data class Success(val value: Int?) : LastConnectErrorValueAttributeSubscriptionState() + data class Error(val exception: Exception) : LastConnectErrorValueAttributeSubscriptionState() - object SubscriptionEstablished : LastConnectErrorValueAttributeSubscriptionState() - } -class SupportedWiFiBandsAttribute( - val value: List? - ) + object SubscriptionEstablished : LastConnectErrorValueAttributeSubscriptionState() + } + + class SupportedWiFiBandsAttribute(val value: List?) sealed class SupportedWiFiBandsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedWiFiBandsAttributeSubscriptionState() - + data class Success(val value: List?) : SupportedWiFiBandsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedWiFiBandsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedWiFiBandsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedWiFiBandsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun scanNetworks(ssid: ByteArray? - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): ScanNetworksResponse { + suspend fun scanNetworks( + ssid: ByteArray?, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): ScanNetworksResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SSID_REQ: Int = 0 - ssid?.let { - tlvWriter.put(ContextSpecificTag(TAG_SSID_REQ), ssid) - } + ssid?.let { tlvWriter.put(ContextSpecificTag(TAG_SSID_REQ), ssid) } val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -236,89 +193,96 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_WI_FI_SCAN_RESULTS: Int = 2 - var wiFiScanResults_decoded: List? = null - + var wiFiScanResults_decoded: List? = + null + val TAG_THREAD_SCAN_RESULTS: Int = 3 - var threadScanResults_decoded: List? = null - + var threadScanResults_decoded: + List? = + null while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_WI_FI_SCAN_RESULTS)) {wiFiScanResults_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_WI_FI_SCAN_RESULTS)) { + wiFiScanResults_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterWiFiInterfaceScanResultStruct.fromTlv(AnonymousTag, tlvReader)) + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add( + NetworkCommissioningClusterWiFiInterfaceScanResultStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } } - tlvReader.exitContainer() - } - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_THREAD_SCAN_RESULTS)) {threadScanResults_decoded = + + if (tag == ContextSpecificTag(TAG_THREAD_SCAN_RESULTS)) { + threadScanResults_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterThreadInterfaceScanResultStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - - else { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add( + NetworkCommissioningClusterThreadInterfaceScanResultStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - tlvReader.exitContainer() @@ -330,13 +294,15 @@ class AttributeListAttribute( ) } - suspend fun addOrUpdateWiFiNetwork(ssid: ByteArray - ,credentials: ByteArray - ,breadcrumb: ULong? - ,networkIdentity: ByteArray? - ,clientIdentifier: ByteArray? - ,possessionNonce: ByteArray? - ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { + suspend fun addOrUpdateWiFiNetwork( + ssid: ByteArray, + credentials: ByteArray, + breadcrumb: ULong?, + networkIdentity: ByteArray?, + clientIdentifier: ByteArray?, + possessionNonce: ByteArray?, + timedInvokeTimeout: Duration? = null + ): NetworkConfigResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -349,9 +315,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_CREDENTIALS_REQ), credentials) val TAG_BREADCRUMB_REQ: Int = 2 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } val TAG_NETWORK_IDENTITY_REQ: Int = 3 networkIdentity?.let { @@ -366,7 +330,7 @@ class AttributeListAttribute( val TAG_POSSESSION_NONCE_REQ: Int = 5 possessionNonce?.let { tlvWriter.put(ContextSpecificTag(TAG_POSSESSION_NONCE_REQ), possessionNonce) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -383,94 +347,88 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - - - tlvReader.exitContainer() @@ -483,9 +441,11 @@ class AttributeListAttribute( ) } - suspend fun addOrUpdateThreadNetwork(operationalDataset: ByteArray - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { + suspend fun addOrUpdateThreadNetwork( + operationalDataset: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): NetworkConfigResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -495,9 +455,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPERATIONAL_DATASET_REQ), operationalDataset) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -514,94 +472,88 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - - - tlvReader.exitContainer() @@ -614,9 +566,11 @@ class AttributeListAttribute( ) } - suspend fun removeNetwork(networkID: ByteArray - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { + suspend fun removeNetwork( + networkID: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): NetworkConfigResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -626,9 +580,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_NETWORK_I_D_REQ), networkID) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -645,94 +597,88 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - - - tlvReader.exitContainer() @@ -745,9 +691,11 @@ class AttributeListAttribute( ) } - suspend fun connectNetwork(networkID: ByteArray - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): ConnectNetworkResponse { + suspend fun connectNetwork( + networkID: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): ConnectNetworkResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -757,9 +705,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_NETWORK_I_D_REQ), networkID) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -776,75 +722,67 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_ERROR_VALUE: Int = 2 var errorValue_decoded: Int? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_ERROR_VALUE)) {errorValue_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_ERROR_VALUE)) { + errorValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getInt(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getInt(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - tlvReader.exitContainer() - return ConnectNetworkResponse( - networkingStatus_decoded, - debugText_decoded, - errorValue_decoded - ) + return ConnectNetworkResponse(networkingStatus_decoded, debugText_decoded, errorValue_decoded) } - suspend fun reorderNetwork(networkID: ByteArray - ,networkIndex: UByte - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { + suspend fun reorderNetwork( + networkID: ByteArray, + networkIndex: UByte, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): NetworkConfigResponse { val commandId: UInt = 8u val tlvWriter = TlvWriter() @@ -857,9 +795,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_NETWORK_INDEX_REQ), networkIndex) val TAG_BREADCRUMB_REQ: Int = 2 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -876,94 +812,88 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - - - tlvReader.exitContainer() @@ -976,9 +906,11 @@ class AttributeListAttribute( ) } - suspend fun queryIdentity(keyIdentifier: ByteArray - ,possessionNonce: ByteArray? - ,timedInvokeTimeout: Duration? = null): QueryIdentityResponse { + suspend fun queryIdentity( + keyIdentifier: ByteArray, + possessionNonce: ByteArray?, + timedInvokeTimeout: Duration? = null + ): QueryIdentityResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -990,7 +922,7 @@ class AttributeListAttribute( val TAG_POSSESSION_NONCE_REQ: Int = 1 possessionNonce?.let { tlvWriter.put(ContextSpecificTag(TAG_POSSESSION_NONCE_REQ), possessionNonce) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1007,87 +939,71 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_IDENTITY: Int = 0 var identity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 1 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_IDENTITY)) {identity_decoded = tlvReader.getByteArray(tag)} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + if (tag == ContextSpecificTag(TAG_IDENTITY)) { + identity_decoded = tlvReader.getByteArray(tag) + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (identity_decoded == null) { - throw IllegalStateException("identity not found in TLV") + throw IllegalStateException("identity not found in TLV") } - - - tlvReader.exitContainer() - return QueryIdentityResponse( - identity_decoded, - possessionSignature_decoded - ) + return QueryIdentityResponse(identity_decoded, possessionSignature_decoded) } -suspend fun readMaxNetworksAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxNetworksAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxnetworks attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxnetworks attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1096,35 +1012,37 @@ suspend fun readMaxNetworksAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxnetworks attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxnetworks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1136,49 +1054,43 @@ suspend fun readMaxNetworksAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNetworksAttribute(): NetworksAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNetworksAttribute(): NetworksAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networks attribute not found in response" - } + } + + requireNotNull(attributeData) { "Networks attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return NetworksAttribute(decodedValue) } @@ -1188,45 +1100,48 @@ suspend fun readNetworksAttribute(): NetworksAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NetworksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NetworksAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networks attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Networks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NetworksAttributeSubscriptionState.Success(decodedValue)) } @@ -1234,47 +1149,41 @@ suspend fun readNetworksAttribute(): NetworksAttribute {val ATTRIBUTE_ID: UInt = emit(NetworksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScanMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readScanMaxTimeSecondsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scanmaxtimeseconds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scanmaxtimeseconds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1284,94 +1193,90 @@ suspend fun readScanMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scanmaxtimeseconds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scanmaxtimeseconds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readConnectMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readConnectMaxTimeSecondsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Connectmaxtimeseconds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Connectmaxtimeseconds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1381,114 +1286,105 @@ suspend fun readConnectMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Connectmaxtimeseconds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Connectmaxtimeseconds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInterfaceEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interfaceenabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Interfaceenabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeInterfaceEnabledAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeInterfaceEnabledAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1510,7 +1406,7 @@ suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInterfaceEnabledAttribute( @@ -1518,34 +1414,38 @@ suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interfaceenabled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Interfaceenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1558,48 +1458,42 @@ suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4 emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastnetworkingstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastnetworkingstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastNetworkingStatusAttribute(decodedValue) } @@ -1609,96 +1503,92 @@ suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastNetworkingStatusAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastNetworkingStatusAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastnetworkingstatus attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastnetworkingstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LastNetworkingStatusAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LastNetworkingStatusAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastNetworkingStatusAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastnetworkid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastnetworkid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastNetworkIDAttribute(decodedValue) } @@ -1708,96 +1598,90 @@ suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastNetworkIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastNetworkIDAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastnetworkid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lastnetworkid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LastNetworkIDAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LastNetworkIDAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastNetworkIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastconnecterrorvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastconnecterrorvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastConnectErrorValueAttribute(decodedValue) } @@ -1807,101 +1691,97 @@ suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastConnectErrorValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastConnectErrorValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastconnecterrorvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastconnecterrorvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LastConnectErrorValueAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LastConnectErrorValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastConnectErrorValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedwifibands attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedwifibands attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedWiFiBandsAttribute(decodedValue) } @@ -1911,100 +1791,96 @@ suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedWiFiBandsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedWiFiBandsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedwifibands attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedwifibands attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SupportedWiFiBandsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SupportedWiFiBandsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SupportedWiFiBandsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedThreadFeaturesAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSupportedThreadFeaturesAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedthreadfeatures attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedthreadfeatures attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2014,94 +1890,90 @@ suspend fun readSupportedThreadFeaturesAttribute(): UShort? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedthreadfeatures attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedthreadfeatures attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThreadVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readThreadVersionAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Threadversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2111,96 +1983,90 @@ suspend fun readThreadVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadversion attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Threadversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2210,45 +2076,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2256,49 +2127,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2308,45 +2173,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2354,49 +2224,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2406,45 +2270,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2452,49 +2319,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2504,45 +2365,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2550,44 +2414,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2596,35 +2453,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2636,44 +2495,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2682,34 +2534,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2722,7 +2578,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt index d34170fb14b72c..d44ee68b808e62 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class NitrogenDioxideConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class NitrogenDioxideConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(NitrogenDioxideConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger(NitrogenDioxideConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1043u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt index f568e8f24179fb..8dd16f44cabe05 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt @@ -17,136 +17,100 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OccupancySensingCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class OccupancySensingCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readOccupancyAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readOccupancyAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupancy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -155,35 +119,37 @@ suspend fun readOccupancyAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Occupancy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,44 +161,37 @@ suspend fun readOccupancyAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupancySensorTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOccupancySensorTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancysensortype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupancysensortype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -241,34 +200,38 @@ suspend fun readOccupancySensorTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancysensortype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupancysensortype attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -281,44 +244,37 @@ suspend fun readOccupancySensorTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupancySensorTypeBitmapAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOccupancySensorTypeBitmapAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancysensortypebitmap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupancysensortypebitmap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -327,34 +283,38 @@ suspend fun readOccupancySensorTypeBitmapAttribute(): UByte {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancysensortypebitmap attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupancysensortypebitmap attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -367,71 +327,64 @@ suspend fun readOccupancySensorTypeBitmapAttribute(): UByte {val ATTRIBUTE_ID: U emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Piroccupiedtounoccupieddelay attribute not found in response" - } + } + + requireNotNull(attributeData) { "Piroccupiedtounoccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePIROccupiedToUnoccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -453,7 +406,7 @@ suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePIROccupiedToUnoccupiedDelayAttribute( @@ -461,118 +414,113 @@ suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Piroccupiedtounoccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Piroccupiedtounoccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupieddelay attribute not found in response" - } + } + + requireNotNull(attributeData) { "Pirunoccupiedtooccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePIRUnoccupiedToOccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -594,7 +542,7 @@ suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePIRUnoccupiedToOccupiedDelayAttribute( @@ -602,118 +550,115 @@ suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 18u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupiedthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupiedthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePIRUnoccupiedToOccupiedThresholdAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -735,7 +680,7 @@ suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBU throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePIRUnoccupiedToOccupiedThresholdAttribute( @@ -743,118 +688,115 @@ suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBU maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupiedthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupiedthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 32u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicoccupiedtounoccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Ultrasonicoccupiedtounoccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUltrasonicOccupiedToUnoccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 32u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -876,7 +818,7 @@ suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUltrasonicOccupiedToUnoccupiedDelayAttribute( @@ -884,118 +826,115 @@ suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicoccupiedtounoccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ultrasonicoccupiedtounoccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 33u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUltrasonicUnoccupiedToOccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1017,7 +956,7 @@ suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUltrasonicUnoccupiedToOccupiedDelayAttribute( @@ -1025,118 +964,115 @@ suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUltrasonicUnoccupiedToOccupiedThresholdAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 34u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1158,7 +1094,7 @@ suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? {val throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUltrasonicUnoccupiedToOccupiedThresholdAttribute( @@ -1166,118 +1102,115 @@ suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactoccupiedtounoccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Physicalcontactoccupiedtounoccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePhysicalContactOccupiedToUnoccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1299,7 +1232,7 @@ suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePhysicalContactOccupiedToUnoccupiedDelayAttribute( @@ -1307,118 +1240,115 @@ suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactoccupiedtounoccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalcontactoccupiedtounoccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePhysicalContactUnoccupiedToOccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1440,7 +1370,7 @@ suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePhysicalContactUnoccupiedToOccupiedDelayAttribute( @@ -1448,118 +1378,115 @@ suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 50u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePhysicalContactUnoccupiedToOccupiedThresholdAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1581,7 +1508,7 @@ suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePhysicalContactUnoccupiedToOccupiedThresholdAttribute( @@ -1589,96 +1516,92 @@ suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1688,45 +1611,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1734,49 +1662,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1786,45 +1708,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1832,49 +1759,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1884,45 +1805,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1930,49 +1854,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1982,45 +1900,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2028,44 +1949,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2074,35 +1988,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2114,44 +2030,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2160,34 +2069,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2200,7 +2113,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt index 8897b4bd04a433..b0801165c6d93c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt @@ -17,119 +17,88 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OnOffCluster(private val controller: MatterController, private val endpointId: UShort) {class StartUpOnOffAttribute( - val value: UByte? - ) +class OnOffCluster(private val controller: MatterController, private val endpointId: UShort) { + class StartUpOnOffAttribute(val value: UByte?) sealed class StartUpOnOffAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpOnOffAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpOnOffAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpOnOffAttributeSubscriptionState() - object SubscriptionEstablished : StartUpOnOffAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : StartUpOnOffAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun off(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -147,7 +116,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -165,7 +134,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -179,9 +148,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun offWithEffect(effectIdentifier: UByte - ,effectVariant: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun offWithEffect( + effectIdentifier: UByte, + effectVariant: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -191,7 +162,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_EFFECT_IDENTIFIER_REQ), effectIdentifier) val TAG_EFFECT_VARIANT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) tlvWriter.endStructure() val request: InvokeRequest = @@ -209,7 +180,7 @@ class AttributeListAttribute( val commandId: UInt = 65u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -223,10 +194,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun onWithTimedOff(onOffControl: UByte - ,onTime: UShort - ,offWaitTime: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun onWithTimedOff( + onOffControl: UByte, + onTime: UShort, + offWaitTime: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 66u val tlvWriter = TlvWriter() @@ -239,7 +212,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ON_TIME_REQ), onTime) val TAG_OFF_WAIT_TIME_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_OFF_WAIT_TIME_REQ), offWaitTime) + tlvWriter.put(ContextSpecificTag(TAG_OFF_WAIT_TIME_REQ), offWaitTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -252,42 +225,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readOnOffAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnOffAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onoff attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onoff attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -296,35 +262,37 @@ suspend fun readOnOffAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onoff attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onoff attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -336,47 +304,41 @@ suspend fun readOnOffAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGlobalSceneControlAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 16384u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGlobalSceneControlAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Globalscenecontrol attribute not found in response" - } + } + + requireNotNull(attributeData) { "Globalscenecontrol attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -386,118 +348,110 @@ suspend fun readGlobalSceneControlAttribute(): Boolean? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Globalscenecontrol attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Globalscenecontrol attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16385u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ontime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ontime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeOnTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16385u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -519,7 +473,7 @@ suspend fun readOnTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16385u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnTimeAttribute( @@ -527,118 +481,108 @@ suspend fun readOnTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16385u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16385u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ontime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Ontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOffWaitTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16386u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOffWaitTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Offwaittime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Offwaittime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeOffWaitTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOffWaitTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16386u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -660,7 +604,7 @@ suspend fun readOffWaitTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16386u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOffWaitTimeAttribute( @@ -668,123 +612,113 @@ suspend fun readOffWaitTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16386u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16386u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Offwaittime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Offwaittime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute {val ATTRIBUTE_ID: UInt = 16387u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startuponoff attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startuponoff attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpOnOffAttribute(decodedValue) } - suspend fun writeStartUpOnOffAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpOnOffAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16387u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -806,7 +740,7 @@ suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute {val ATTRIBUTE_ID throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpOnOffAttribute( @@ -814,101 +748,95 @@ suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16387u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpOnOffAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpOnOffAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startuponoff attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startuponoff attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpOnOffAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpOnOffAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpOnOffAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -918,45 +846,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -964,49 +897,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1016,45 +943,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1062,49 +994,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1114,45 +1040,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1160,49 +1089,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1212,45 +1135,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1258,44 +1184,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1304,35 +1223,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1344,44 +1265,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1390,34 +1304,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1430,7 +1348,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt index d30268d4c2280c..7359a28163aae6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt @@ -17,136 +17,100 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OnOffSwitchConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class OnOffSwitchConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSwitchTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSwitchTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Switchtype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Switchtype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -155,35 +119,37 @@ suspend fun readSwitchTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Switchtype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Switchtype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,67 +161,56 @@ suspend fun readSwitchTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSwitchActionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSwitchActionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Switchactions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Switchactions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeSwitchActionsAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSwitchActionsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -277,7 +232,7 @@ suspend fun readSwitchActionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSwitchActionsAttribute( @@ -285,35 +240,37 @@ suspend fun readSwitchActionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Switchactions attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Switchactions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -325,49 +282,43 @@ suspend fun readSwitchActionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -377,45 +328,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -423,49 +379,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -475,45 +425,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -521,49 +476,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -573,45 +522,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -619,49 +571,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -671,45 +617,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -717,44 +666,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -763,35 +705,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -803,44 +747,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -849,34 +786,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -889,7 +830,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt index ee45ff6bc3af2a..cfc1103e4216f4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt @@ -17,169 +17,129 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalCredentialsCluster(private val controller: MatterController, private val endpointId: UShort) { +class OperationalCredentialsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class AttestationResponse( - val attestationElements: ByteArray, + val attestationElements: ByteArray, val attestationSignature: ByteArray ) - class CertificateChainResponse( - val certificate: ByteArray - ) + class CertificateChainResponse(val certificate: ByteArray) - class CSRResponse( - val NOCSRElements: ByteArray, - val attestationSignature: ByteArray - ) + class CSRResponse(val NOCSRElements: ByteArray, val attestationSignature: ByteArray) - class NOCResponse( - val statusCode: UByte, - val fabricIndex: UByte?, - val debugText: String? - ) -class NOCsAttribute( - val value: List - ) + class NOCResponse(val statusCode: UByte, val fabricIndex: UByte?, val debugText: String?) + + class NOCsAttribute(val value: List) sealed class NOCsAttributeSubscriptionState { - data class Success( - val value: List - ) : NOCsAttributeSubscriptionState() - + data class Success(val value: List) : + NOCsAttributeSubscriptionState() + data class Error(val exception: Exception) : NOCsAttributeSubscriptionState() - object SubscriptionEstablished : NOCsAttributeSubscriptionState() - } -class FabricsAttribute( - val value: List - ) + object SubscriptionEstablished : NOCsAttributeSubscriptionState() + } + + class FabricsAttribute(val value: List) sealed class FabricsAttributeSubscriptionState { - data class Success( - val value: List - ) : FabricsAttributeSubscriptionState() - + data class Success(val value: List) : + FabricsAttributeSubscriptionState() + data class Error(val exception: Exception) : FabricsAttributeSubscriptionState() - object SubscriptionEstablished : FabricsAttributeSubscriptionState() - } -class TrustedRootCertificatesAttribute( - val value: List - ) + object SubscriptionEstablished : FabricsAttributeSubscriptionState() + } + + class TrustedRootCertificatesAttribute(val value: List) sealed class TrustedRootCertificatesAttributeSubscriptionState { - data class Success( - val value: List - ) : TrustedRootCertificatesAttributeSubscriptionState() - - data class Error(val exception: Exception) : TrustedRootCertificatesAttributeSubscriptionState() - - object SubscriptionEstablished : TrustedRootCertificatesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List) : + TrustedRootCertificatesAttributeSubscriptionState() + + data class Error(val exception: Exception) : + TrustedRootCertificatesAttributeSubscriptionState() + + object SubscriptionEstablished : TrustedRootCertificatesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun attestationRequest(attestationNonce: ByteArray - ,timedInvokeTimeout: Duration? = null): AttestationResponse { + suspend fun attestationRequest( + attestationNonce: ByteArray, + timedInvokeTimeout: Duration? = null + ): AttestationResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ATTESTATION_NONCE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ATTESTATION_NONCE_REQ), attestationNonce) + tlvWriter.put(ContextSpecificTag(TAG_ATTESTATION_NONCE_REQ), attestationNonce) tlvWriter.endStructure() val request: InvokeRequest = @@ -196,54 +156,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ATTESTATION_ELEMENTS: Int = 0 var attestationElements_decoded: ByteArray? = null - + val TAG_ATTESTATION_SIGNATURE: Int = 1 var attestationSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ATTESTATION_ELEMENTS)) {attestationElements_decoded = tlvReader.getByteArray(tag)} - - if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) {attestationSignature_decoded = tlvReader.getByteArray(tag)} - + if (tag == ContextSpecificTag(TAG_ATTESTATION_ELEMENTS)) { + attestationElements_decoded = tlvReader.getByteArray(tag) + } - else { + if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) { + attestationSignature_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (attestationElements_decoded == null) { - throw IllegalStateException("attestationElements not found in TLV") + throw IllegalStateException("attestationElements not found in TLV") } - - + if (attestationSignature_decoded == null) { - throw IllegalStateException("attestationSignature not found in TLV") + throw IllegalStateException("attestationSignature not found in TLV") } - tlvReader.exitContainer() - return AttestationResponse( - attestationElements_decoded, - attestationSignature_decoded - ) + return AttestationResponse(attestationElements_decoded, attestationSignature_decoded) } - suspend fun certificateChainRequest(certificateType: UByte - ,timedInvokeTimeout: Duration? = null): CertificateChainResponse { + suspend fun certificateChainRequest( + certificateType: UByte, + timedInvokeTimeout: Duration? = null + ): CertificateChainResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_CERTIFICATE_TYPE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_CERTIFICATE_TYPE_REQ), certificateType) + tlvWriter.put(ContextSpecificTag(TAG_CERTIFICATE_TYPE_REQ), certificateType) tlvWriter.endStructure() val request: InvokeRequest = @@ -260,37 +214,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_CERTIFICATE: Int = 0 var certificate_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_CERTIFICATE)) {certificate_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_CERTIFICATE)) { + certificate_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (certificate_decoded == null) { - throw IllegalStateException("certificate not found in TLV") + throw IllegalStateException("certificate not found in TLV") } - tlvReader.exitContainer() - return CertificateChainResponse( - certificate_decoded - ) + return CertificateChainResponse(certificate_decoded) } - suspend fun CSRRequest(CSRNonce: ByteArray - ,isForUpdateNOC: Boolean? - ,timedInvokeTimeout: Duration? = null): CSRResponse { + suspend fun CSRRequest( + CSRNonce: ByteArray, + isForUpdateNOC: Boolean?, + timedInvokeTimeout: Duration? = null + ): CSRResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -302,7 +250,7 @@ class AttributeListAttribute( val TAG_IS_FOR_UPDATE_N_O_C_REQ: Int = 1 isForUpdateNOC?.let { tlvWriter.put(ContextSpecificTag(TAG_IS_FOR_UPDATE_N_O_C_REQ), isForUpdateNOC) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -319,51 +267,45 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_N_O_C_S_R_ELEMENTS: Int = 0 var NOCSRElements_decoded: ByteArray? = null - + val TAG_ATTESTATION_SIGNATURE: Int = 1 var attestationSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_N_O_C_S_R_ELEMENTS)) {NOCSRElements_decoded = tlvReader.getByteArray(tag)} - - if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) {attestationSignature_decoded = tlvReader.getByteArray(tag)} - + if (tag == ContextSpecificTag(TAG_N_O_C_S_R_ELEMENTS)) { + NOCSRElements_decoded = tlvReader.getByteArray(tag) + } - else { + if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) { + attestationSignature_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (NOCSRElements_decoded == null) { - throw IllegalStateException("NOCSRElements not found in TLV") + throw IllegalStateException("NOCSRElements not found in TLV") } - - + if (attestationSignature_decoded == null) { - throw IllegalStateException("attestationSignature not found in TLV") + throw IllegalStateException("attestationSignature not found in TLV") } - tlvReader.exitContainer() - return CSRResponse( - NOCSRElements_decoded, - attestationSignature_decoded - ) + return CSRResponse(NOCSRElements_decoded, attestationSignature_decoded) } - suspend fun addNOC(NOCValue: ByteArray - ,ICACValue: ByteArray? - ,IPKValue: ByteArray - ,caseAdminSubject: ULong - ,adminVendorId: UShort - ,timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun addNOC( + NOCValue: ByteArray, + ICACValue: ByteArray?, + IPKValue: ByteArray, + caseAdminSubject: ULong, + adminVendorId: UShort, + timedInvokeTimeout: Duration? = null + ): NOCResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -373,9 +315,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_N_O_C_VALUE_REQ), NOCValue) val TAG_I_C_A_C_VALUE_REQ: Int = 1 - ICACValue?.let { - tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) - } + ICACValue?.let { tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) } val TAG_I_P_K_VALUE_REQ: Int = 2 tlvWriter.put(ContextSpecificTag(TAG_I_P_K_VALUE_REQ), IPKValue) @@ -384,7 +324,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_CASE_ADMIN_SUBJECT_REQ), caseAdminSubject) val TAG_ADMIN_VENDOR_ID_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_ADMIN_VENDOR_ID_REQ), adminVendorId) + tlvWriter.put(ContextSpecificTag(TAG_ADMIN_VENDOR_ID_REQ), adminVendorId) tlvWriter.endStructure() val request: InvokeRequest = @@ -401,73 +341,65 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } - - - - - tlvReader.exitContainer() - return NOCResponse( - statusCode_decoded, - fabricIndex_decoded, - debugText_decoded - ) + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) } - suspend fun updateNOC(NOCValue: ByteArray - ,ICACValue: ByteArray? - ,timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun updateNOC( + NOCValue: ByteArray, + ICACValue: ByteArray?, + timedInvokeTimeout: Duration? = null + ): NOCResponse { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -477,9 +409,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_N_O_C_VALUE_REQ), NOCValue) val TAG_I_C_A_C_VALUE_REQ: Int = 1 - ICACValue?.let { - tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) - } + ICACValue?.let { tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) } tlvWriter.endStructure() val request: InvokeRequest = @@ -496,79 +426,68 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } - - - - - tlvReader.exitContainer() - return NOCResponse( - statusCode_decoded, - fabricIndex_decoded, - debugText_decoded - ) + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) } - suspend fun updateFabricLabel(label: String - ,timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun updateFabricLabel(label: String, timedInvokeTimeout: Duration? = null): NOCResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LABEL_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LABEL_REQ), label) + tlvWriter.put(ContextSpecificTag(TAG_LABEL_REQ), label) tlvWriter.endStructure() val request: InvokeRequest = @@ -585,79 +504,68 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } - - - - - tlvReader.exitContainer() - return NOCResponse( - statusCode_decoded, - fabricIndex_decoded, - debugText_decoded - ) + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) } - suspend fun removeFabric(fabricIndex: UByte - ,timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun removeFabric(fabricIndex: UByte, timedInvokeTimeout: Duration? = null): NOCResponse { val commandId: UInt = 10u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_FABRIC_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_FABRIC_INDEX_REQ), fabricIndex) + tlvWriter.put(ContextSpecificTag(TAG_FABRIC_INDEX_REQ), fabricIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -674,79 +582,71 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } - - - - - tlvReader.exitContainer() - return NOCResponse( - statusCode_decoded, - fabricIndex_decoded, - debugText_decoded - ) + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) } - suspend fun addTrustedRootCertificate(rootCACertificate: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun addTrustedRootCertificate( + rootCACertificate: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ROOT_C_A_CERTIFICATE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ROOT_C_A_CERTIFICATE_REQ), rootCACertificate) + tlvWriter.put(ContextSpecificTag(TAG_ROOT_C_A_CERTIFICATE_REQ), rootCACertificate) tlvWriter.endStructure() val request: InvokeRequest = @@ -759,47 +659,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readNOCsAttribute(): NOCsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNOCsAttribute(): NOCsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nocs attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nocs attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return NOCsAttribute(decodedValue) } @@ -809,45 +703,48 @@ suspend fun readNOCsAttribute(): NOCsAttribute {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NOCsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NOCsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nocs attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nocs attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NOCsAttributeSubscriptionState.Success(decodedValue)) } @@ -855,49 +752,43 @@ suspend fun readNOCsAttribute(): NOCsAttribute {val ATTRIBUTE_ID: UInt = 0u emit(NOCsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFabricsAttribute(): FabricsAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFabricsAttribute(): FabricsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fabrics attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fabrics attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return FabricsAttribute(decodedValue) } @@ -907,45 +798,53 @@ suspend fun readFabricsAttribute(): FabricsAttribute {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FabricsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FabricsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fabrics attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Fabrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + OperationalCredentialsClusterFabricDescriptorStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(FabricsAttributeSubscriptionState.Success(decodedValue)) } @@ -953,44 +852,37 @@ suspend fun readFabricsAttribute(): FabricsAttribute {val ATTRIBUTE_ID: UInt = 1 emit(FabricsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedFabricsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedfabrics attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedfabrics attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -999,34 +891,38 @@ suspend fun readSupportedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedfabrics attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedfabrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1039,44 +935,37 @@ suspend fun readSupportedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCommissionedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCommissionedFabricsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Commissionedfabrics attribute not found in response" - } + } + + requireNotNull(attributeData) { "Commissionedfabrics attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1085,34 +974,38 @@ suspend fun readCommissionedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Commissionedfabrics attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Commissionedfabrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1125,49 +1018,43 @@ suspend fun readCommissionedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Trustedrootcertificates attribute not found in response" - } + } + + requireNotNull(attributeData) { "Trustedrootcertificates attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return TrustedRootCertificatesAttribute(decodedValue) } @@ -1177,45 +1064,50 @@ suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TrustedRootCertificatesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TrustedRootCertificatesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Trustedrootcertificates attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Trustedrootcertificates attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(TrustedRootCertificatesAttributeSubscriptionState.Success(decodedValue)) } @@ -1223,44 +1115,37 @@ suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttri emit(TrustedRootCertificatesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentFabricIndexAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentFabricIndexAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentfabricindex attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentfabricindex attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1269,34 +1154,38 @@ suspend fun readCurrentFabricIndexAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentfabricindex attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentfabricindex attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1309,49 +1198,43 @@ suspend fun readCurrentFabricIndexAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1361,45 +1244,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1407,49 +1295,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1459,45 +1341,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1505,49 +1392,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1557,45 +1438,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1603,49 +1487,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1655,45 +1533,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1701,44 +1582,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1747,35 +1621,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1787,44 +1663,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1833,34 +1702,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1873,7 +1746,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt index e9f4f326e1fdbe..68dd297ecea977 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt @@ -17,175 +17,136 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalStateCluster(private val controller: MatterController, private val endpointId: UShort) { +class OperationalStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class OperationalCommandResponse( val commandResponseState: OperationalStateClusterErrorStateStruct ) -class PhaseListAttribute( - val value: List? - ) + + class PhaseListAttribute(val value: List?) sealed class PhaseListAttributeSubscriptionState { - data class Success( - val value: List? - ) : PhaseListAttributeSubscriptionState() - + data class Success(val value: List?) : PhaseListAttributeSubscriptionState() + data class Error(val exception: Exception) : PhaseListAttributeSubscriptionState() - object SubscriptionEstablished : PhaseListAttributeSubscriptionState() - } -class CurrentPhaseAttribute( - val value: UByte? - ) + object SubscriptionEstablished : PhaseListAttributeSubscriptionState() + } + + class CurrentPhaseAttribute(val value: UByte?) sealed class CurrentPhaseAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPhaseAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentPhaseAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPhaseAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() - } -class CountdownTimeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() + } + + class CountdownTimeAttribute(val value: UInt?) sealed class CountdownTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : CountdownTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : CountdownTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : CountdownTimeAttributeSubscriptionState() - object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() - } -class OperationalStateListAttribute( + object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() + } + + class OperationalStateListAttribute( val value: List ) sealed class OperationalStateListAttributeSubscriptionState { - data class Success( - val value: List - ) : OperationalStateListAttributeSubscriptionState() - + data class Success(val value: List) : + OperationalStateListAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalStateListAttributeSubscriptionState() - object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() - } -class OperationalErrorAttribute( - val value: OperationalStateClusterErrorStateStruct - ) + object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() + } + + class OperationalErrorAttribute(val value: OperationalStateClusterErrorStateStruct) sealed class OperationalErrorAttributeSubscriptionState { - data class Success( - val value: OperationalStateClusterErrorStateStruct - ) : OperationalErrorAttributeSubscriptionState() - + data class Success(val value: OperationalStateClusterErrorStateStruct) : + OperationalErrorAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalErrorAttributeSubscriptionState() - object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun pause(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -202,39 +163,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun stop(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -251,39 +205,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun start(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -300,39 +247,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -349,79 +289,66 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } -suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhaseListAttribute(): PhaseListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Phaselist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return PhaseListAttribute(decodedValue) } @@ -431,102 +358,96 @@ suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PhaseListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PhaseListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Phaselist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PhaseListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PhaseListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PhaseListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentphase attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPhaseAttribute(decodedValue) } @@ -536,100 +457,94 @@ suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPhaseAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPhaseAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentphase attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPhaseAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPhaseAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPhaseAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Countdowntime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CountdownTimeAttribute(decodedValue) } @@ -639,101 +554,95 @@ suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CountdownTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CountdownTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Countdowntime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CountdownTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CountdownTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CountdownTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return OperationalStateListAttribute(decodedValue) } @@ -743,45 +652,50 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalStateListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalStateListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(OperationalStateListAttributeSubscriptionState.Success(decodedValue)) } @@ -789,44 +703,37 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { emit(OperationalStateListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -835,34 +742,38 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -875,43 +786,37 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalerror attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OperationalStateClusterErrorStateStruct = OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: OperationalStateClusterErrorStateStruct = + OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) return OperationalErrorAttribute(decodedValue) } @@ -921,39 +826,44 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalErrorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalErrorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OperationalStateClusterErrorStateStruct = OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: OperationalStateClusterErrorStateStruct = + OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) emit(OperationalErrorAttributeSubscriptionState.Success(decodedValue)) } @@ -961,49 +871,43 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR emit(OperationalErrorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1013,45 +917,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1059,49 +968,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1111,45 +1014,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1157,49 +1065,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1209,45 +1111,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1255,49 +1160,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1307,45 +1206,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1353,44 +1255,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1399,35 +1294,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1439,44 +1336,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1485,34 +1375,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1525,7 +1419,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt index ad0f41fcd07f31..5f109918016959 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt @@ -17,126 +17,96 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateProviderCluster(private val controller: MatterController, private val endpointId: UShort) { +class OtaSoftwareUpdateProviderCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class QueryImageResponse( - val status: UByte, - val delayedActionTime: UInt?, - val imageURI: String?, - val softwareVersion: UInt?, - val softwareVersionString: String?, - val updateToken: ByteArray?, - val userConsentNeeded: Boolean?, + val status: UByte, + val delayedActionTime: UInt?, + val imageURI: String?, + val softwareVersion: UInt?, + val softwareVersionString: String?, + val updateToken: ByteArray?, + val userConsentNeeded: Boolean?, val metadataForRequestor: ByteArray? ) - class ApplyUpdateResponse( - val action: UByte, - val delayedActionTime: UInt - ) -class GeneratedCommandListAttribute( - val value: List - ) + class ApplyUpdateResponse(val action: UByte, val delayedActionTime: UInt) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun queryImage(vendorID: UShort - ,productID: UShort - ,softwareVersion: UInt - ,protocolsSupported: List - ,hardwareVersion: UShort? - ,location: String? - ,requestorCanConsent: Boolean? - ,metadataForProvider: ByteArray? - ,timedInvokeTimeout: Duration? = null): QueryImageResponse { + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun queryImage( + vendorID: UShort, + productID: UShort, + softwareVersion: UInt, + protocolsSupported: List, + hardwareVersion: UShort?, + location: String?, + requestorCanConsent: Boolean?, + metadataForProvider: ByteArray?, + timedInvokeTimeout: Duration? = null + ): QueryImageResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -153,10 +123,10 @@ class AttributeListAttribute( val TAG_PROTOCOLS_SUPPORTED_REQ: Int = 3 tlvWriter.startArray(ContextSpecificTag(TAG_PROTOCOLS_SUPPORTED_REQ)) - for (item in protocolsSupported.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in protocolsSupported.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val TAG_HARDWARE_VERSION_REQ: Int = 4 hardwareVersion?.let { @@ -164,9 +134,7 @@ class AttributeListAttribute( } val TAG_LOCATION_REQ: Int = 5 - location?.let { - tlvWriter.put(ContextSpecificTag(TAG_LOCATION_REQ), location) - } + location?.let { tlvWriter.put(ContextSpecificTag(TAG_LOCATION_REQ), location) } val TAG_REQUESTOR_CAN_CONSENT_REQ: Int = 6 requestorCanConsent?.let { @@ -176,7 +144,7 @@ class AttributeListAttribute( val TAG_METADATA_FOR_PROVIDER_REQ: Int = 7 metadataForProvider?.let { tlvWriter.put(ContextSpecificTag(TAG_METADATA_FOR_PROVIDER_REQ), metadataForProvider) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -193,145 +161,139 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DELAYED_ACTION_TIME: Int = 1 var delayedActionTime_decoded: UInt? = null - + val TAG_IMAGE_U_R_I: Int = 2 var imageURI_decoded: String? = null - + val TAG_SOFTWARE_VERSION: Int = 3 var softwareVersion_decoded: UInt? = null - + val TAG_SOFTWARE_VERSION_STRING: Int = 4 var softwareVersionString_decoded: String? = null - + val TAG_UPDATE_TOKEN: Int = 5 var updateToken_decoded: ByteArray? = null - + val TAG_USER_CONSENT_NEEDED: Int = 6 var userConsentNeeded_decoded: Boolean? = null - + val TAG_METADATA_FOR_REQUESTOR: Int = 7 var metadataForRequestor_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) {delayedActionTime_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) { + delayedActionTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_IMAGE_U_R_I)) {imageURI_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_IMAGE_U_R_I)) { + imageURI_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION)) {softwareVersion_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION)) { + softwareVersion_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION_STRING)) {softwareVersionString_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION_STRING)) { + softwareVersionString_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_UPDATE_TOKEN)) {updateToken_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_UPDATE_TOKEN)) { + updateToken_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_USER_CONSENT_NEEDED)) {userConsentNeeded_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_CONSENT_NEEDED)) { + userConsentNeeded_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_METADATA_FOR_REQUESTOR)) {metadataForRequestor_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_METADATA_FOR_REQUESTOR)) { + metadataForRequestor_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - - - - - - - - - - - tlvReader.exitContainer() @@ -347,9 +309,11 @@ class AttributeListAttribute( ) } - suspend fun applyUpdateRequest(updateToken: ByteArray - ,newVersion: UInt - ,timedInvokeTimeout: Duration? = null): ApplyUpdateResponse { + suspend fun applyUpdateRequest( + updateToken: ByteArray, + newVersion: UInt, + timedInvokeTimeout: Duration? = null + ): ApplyUpdateResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -359,7 +323,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_UPDATE_TOKEN_REQ), updateToken) val TAG_NEW_VERSION_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NEW_VERSION_REQ), newVersion) + tlvWriter.put(ContextSpecificTag(TAG_NEW_VERSION_REQ), newVersion) tlvWriter.endStructure() val request: InvokeRequest = @@ -376,48 +340,42 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ACTION: Int = 0 var action_decoded: UByte? = null - + val TAG_DELAYED_ACTION_TIME: Int = 1 var delayedActionTime_decoded: UInt? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ACTION)) {action_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) {delayedActionTime_decoded = tlvReader.getUInt(tag)} - + if (tag == ContextSpecificTag(TAG_ACTION)) { + action_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) { + delayedActionTime_decoded = tlvReader.getUInt(tag) + } else { tlvReader.skipElement() } } - - if (action_decoded == null) { - throw IllegalStateException("action not found in TLV") + throw IllegalStateException("action not found in TLV") } - - + if (delayedActionTime_decoded == null) { - throw IllegalStateException("delayedActionTime not found in TLV") + throw IllegalStateException("delayedActionTime not found in TLV") } - tlvReader.exitContainer() - return ApplyUpdateResponse( - action_decoded, - delayedActionTime_decoded - ) + return ApplyUpdateResponse(action_decoded, delayedActionTime_decoded) } - suspend fun notifyUpdateApplied(updateToken: ByteArray - ,softwareVersion: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun notifyUpdateApplied( + updateToken: ByteArray, + softwareVersion: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -427,7 +385,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_UPDATE_TOKEN_REQ), updateToken) val TAG_SOFTWARE_VERSION_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SOFTWARE_VERSION_REQ), softwareVersion) + tlvWriter.put(ContextSpecificTag(TAG_SOFTWARE_VERSION_REQ), softwareVersion) tlvWriter.endStructure() val request: InvokeRequest = @@ -440,47 +398,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -490,45 +442,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -536,49 +493,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -588,45 +539,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -634,49 +590,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -686,45 +636,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -732,49 +685,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -784,45 +731,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -830,44 +780,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -876,35 +819,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -916,44 +861,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -962,34 +900,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1002,7 +944,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt index 1309276b36b0d1..35f2a59e30fac9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt @@ -17,133 +17,108 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateRequestorCluster(private val controller: MatterController, private val endpointId: UShort) {class DefaultOTAProvidersAttribute( +class OtaSoftwareUpdateRequestorCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class DefaultOTAProvidersAttribute( val value: List ) sealed class DefaultOTAProvidersAttributeSubscriptionState { - data class Success( - val value: List - ) : DefaultOTAProvidersAttributeSubscriptionState() - + data class Success(val value: List) : + DefaultOTAProvidersAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultOTAProvidersAttributeSubscriptionState() - object SubscriptionEstablished : DefaultOTAProvidersAttributeSubscriptionState() - } -class UpdateStateProgressAttribute( - val value: UByte? - ) + object SubscriptionEstablished : DefaultOTAProvidersAttributeSubscriptionState() + } + + class UpdateStateProgressAttribute(val value: UByte?) sealed class UpdateStateProgressAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : UpdateStateProgressAttributeSubscriptionState() - + data class Success(val value: UByte?) : UpdateStateProgressAttributeSubscriptionState() + data class Error(val exception: Exception) : UpdateStateProgressAttributeSubscriptionState() - object SubscriptionEstablished : UpdateStateProgressAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : UpdateStateProgressAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun announceOTAProvider(providerNodeID: ULong - ,vendorID: UShort - ,announcementReason: UByte - ,metadataForNode: ByteArray? - ,endpoint: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun announceOTAProvider( + providerNodeID: ULong, + vendorID: UShort, + announcementReason: UByte, + metadataForNode: ByteArray?, + endpoint: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -164,7 +139,7 @@ class AttributeListAttribute( } val TAG_ENDPOINT_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_ENDPOINT_REQ), endpoint) + tlvWriter.put(ContextSpecificTag(TAG_ENDPOINT_REQ), endpoint) tlvWriter.endStructure() val request: InvokeRequest = @@ -177,75 +152,68 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultotaproviders attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultotaproviders attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return DefaultOTAProvidersAttribute(decodedValue) } suspend fun writeDefaultOTAProvidersAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -267,7 +235,7 @@ suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultOTAProvidersAttribute( @@ -275,45 +243,52 @@ suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DefaultOTAProvidersAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DefaultOTAProvidersAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultotaproviders attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultotaproviders attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } emit(DefaultOTAProvidersAttributeSubscriptionState.Success(decodedValue)) } @@ -321,44 +296,37 @@ suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute {va emit(DefaultOTAProvidersAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUpdatePossibleAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUpdatePossibleAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatepossible attribute not found in response" - } + } + + requireNotNull(attributeData) { "Updatepossible attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -367,34 +335,38 @@ suspend fun readUpdatePossibleAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatepossible attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Updatepossible attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -407,44 +379,37 @@ suspend fun readUpdatePossibleAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUpdateStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUpdateStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatestate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Updatestate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -453,35 +418,37 @@ suspend fun readUpdateStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatestate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Updatestate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -493,48 +460,42 @@ suspend fun readUpdateStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatestateprogress attribute not found in response" - } + } + + requireNotNull(attributeData) { "Updatestateprogress attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return UpdateStateProgressAttribute(decodedValue) } @@ -544,97 +505,93 @@ suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UpdateStateProgressAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UpdateStateProgressAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatestateprogress attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Updatestateprogress attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UpdateStateProgressAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UpdateStateProgressAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UpdateStateProgressAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -644,45 +601,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -690,49 +652,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -742,45 +698,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -788,49 +749,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -840,45 +795,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -886,49 +844,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -938,45 +890,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -984,44 +939,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1030,35 +978,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1070,44 +1020,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1116,34 +1059,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1156,7 +1103,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt index 4ca4bd4f9307c1..86aeb3500ceee6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt @@ -17,175 +17,136 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenCavityOperationalStateCluster(private val controller: MatterController, private val endpointId: UShort) { +class OvenCavityOperationalStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class OperationalCommandResponse( val commandResponseState: OvenCavityOperationalStateClusterErrorStateStruct ) -class PhaseListAttribute( - val value: List? - ) + + class PhaseListAttribute(val value: List?) sealed class PhaseListAttributeSubscriptionState { - data class Success( - val value: List? - ) : PhaseListAttributeSubscriptionState() - + data class Success(val value: List?) : PhaseListAttributeSubscriptionState() + data class Error(val exception: Exception) : PhaseListAttributeSubscriptionState() - object SubscriptionEstablished : PhaseListAttributeSubscriptionState() - } -class CurrentPhaseAttribute( - val value: UByte? - ) + object SubscriptionEstablished : PhaseListAttributeSubscriptionState() + } + + class CurrentPhaseAttribute(val value: UByte?) sealed class CurrentPhaseAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPhaseAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentPhaseAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPhaseAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() - } -class CountdownTimeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() + } + + class CountdownTimeAttribute(val value: UInt?) sealed class CountdownTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : CountdownTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : CountdownTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : CountdownTimeAttributeSubscriptionState() - object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() - } -class OperationalStateListAttribute( + object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() + } + + class OperationalStateListAttribute( val value: List ) sealed class OperationalStateListAttributeSubscriptionState { - data class Success( - val value: List - ) : OperationalStateListAttributeSubscriptionState() - + data class Success(val value: List) : + OperationalStateListAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalStateListAttributeSubscriptionState() - object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() - } -class OperationalErrorAttribute( - val value: OvenCavityOperationalStateClusterErrorStateStruct - ) + object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() + } + + class OperationalErrorAttribute(val value: OvenCavityOperationalStateClusterErrorStateStruct) sealed class OperationalErrorAttributeSubscriptionState { - data class Success( - val value: OvenCavityOperationalStateClusterErrorStateStruct - ) : OperationalErrorAttributeSubscriptionState() - + data class Success(val value: OvenCavityOperationalStateClusterErrorStateStruct) : + OperationalErrorAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalErrorAttributeSubscriptionState() - object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun pause(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -202,39 +163,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun stop(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -251,39 +205,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun start(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -300,39 +247,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -349,79 +289,66 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } -suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhaseListAttribute(): PhaseListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Phaselist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return PhaseListAttribute(decodedValue) } @@ -431,102 +358,96 @@ suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PhaseListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PhaseListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Phaselist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PhaseListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PhaseListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PhaseListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentphase attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPhaseAttribute(decodedValue) } @@ -536,100 +457,94 @@ suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPhaseAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPhaseAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentphase attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPhaseAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPhaseAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPhaseAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Countdowntime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CountdownTimeAttribute(decodedValue) } @@ -639,101 +554,97 @@ suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CountdownTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CountdownTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Countdowntime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CountdownTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CountdownTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CountdownTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return OperationalStateListAttribute(decodedValue) } @@ -743,45 +654,55 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalStateListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalStateListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(OperationalStateListAttributeSubscriptionState.Success(decodedValue)) } @@ -789,44 +710,37 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { emit(OperationalStateListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -835,34 +749,38 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -875,43 +793,37 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalerror attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) return OperationalErrorAttribute(decodedValue) } @@ -921,39 +833,44 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalErrorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalErrorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) emit(OperationalErrorAttributeSubscriptionState.Success(decodedValue)) } @@ -961,49 +878,43 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR emit(OperationalErrorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1013,45 +924,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1059,49 +975,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1111,45 +1021,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1157,49 +1072,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1209,45 +1118,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1255,49 +1167,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1307,45 +1213,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1353,44 +1262,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1399,35 +1301,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1439,44 +1343,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1485,34 +1382,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1525,7 +1426,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt index 072808ed1b0f75..8dcff4690b2aa5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt @@ -17,154 +17,117 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class OvenModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +144,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +224,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +275,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +314,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +356,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +437,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +445,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +578,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +586,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +684,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +735,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +781,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +832,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +878,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +927,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +973,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1022,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1061,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1103,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1142,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,7 +1186,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt index 427cf896b35373..c660d89a0f566c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class OzoneConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class OzoneConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt index 0105d1d2a3b075..d81ab6b7f6574d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class Pm10ConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class Pm10ConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt index 56a19df1bc928d..9f880bbbec52d7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class Pm1ConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class Pm1ConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt index 090d17ca0c1584..cfd4cda6106049 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class Pm25ConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class Pm25ConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt index 835ea746f9a7d8..e5df8e8e29a31d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt @@ -17,292 +17,218 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class PowerSourceCluster(private val controller: MatterController, private val endpointId: UShort) {class WiredAssessedInputVoltageAttribute( - val value: UInt? - ) +class PowerSourceCluster(private val controller: MatterController, private val endpointId: UShort) { + class WiredAssessedInputVoltageAttribute(val value: UInt?) sealed class WiredAssessedInputVoltageAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : WiredAssessedInputVoltageAttributeSubscriptionState() - - data class Error(val exception: Exception) : WiredAssessedInputVoltageAttributeSubscriptionState() - - object SubscriptionEstablished : WiredAssessedInputVoltageAttributeSubscriptionState() - } -class WiredAssessedInputFrequencyAttribute( - val value: UShort? - ) + data class Success(val value: UInt?) : WiredAssessedInputVoltageAttributeSubscriptionState() + + data class Error(val exception: Exception) : + WiredAssessedInputVoltageAttributeSubscriptionState() + + object SubscriptionEstablished : WiredAssessedInputVoltageAttributeSubscriptionState() + } + + class WiredAssessedInputFrequencyAttribute(val value: UShort?) sealed class WiredAssessedInputFrequencyAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : WiredAssessedInputFrequencyAttributeSubscriptionState() - - data class Error(val exception: Exception) : WiredAssessedInputFrequencyAttributeSubscriptionState() - - object SubscriptionEstablished : WiredAssessedInputFrequencyAttributeSubscriptionState() - } -class WiredAssessedCurrentAttribute( - val value: UInt? - ) + data class Success(val value: UShort?) : + WiredAssessedInputFrequencyAttributeSubscriptionState() + + data class Error(val exception: Exception) : + WiredAssessedInputFrequencyAttributeSubscriptionState() + + object SubscriptionEstablished : WiredAssessedInputFrequencyAttributeSubscriptionState() + } + + class WiredAssessedCurrentAttribute(val value: UInt?) sealed class WiredAssessedCurrentAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : WiredAssessedCurrentAttributeSubscriptionState() - + data class Success(val value: UInt?) : WiredAssessedCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : WiredAssessedCurrentAttributeSubscriptionState() - object SubscriptionEstablished : WiredAssessedCurrentAttributeSubscriptionState() - } -class ActiveWiredFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : WiredAssessedCurrentAttributeSubscriptionState() + } + + class ActiveWiredFaultsAttribute(val value: List?) sealed class ActiveWiredFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveWiredFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveWiredFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveWiredFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveWiredFaultsAttributeSubscriptionState() - } -class BatVoltageAttribute( - val value: UInt? - ) + object SubscriptionEstablished : ActiveWiredFaultsAttributeSubscriptionState() + } + + class BatVoltageAttribute(val value: UInt?) sealed class BatVoltageAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BatVoltageAttributeSubscriptionState() - + data class Success(val value: UInt?) : BatVoltageAttributeSubscriptionState() + data class Error(val exception: Exception) : BatVoltageAttributeSubscriptionState() - object SubscriptionEstablished : BatVoltageAttributeSubscriptionState() - } -class BatPercentRemainingAttribute( - val value: UByte? - ) + object SubscriptionEstablished : BatVoltageAttributeSubscriptionState() + } + + class BatPercentRemainingAttribute(val value: UByte?) sealed class BatPercentRemainingAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : BatPercentRemainingAttributeSubscriptionState() - + data class Success(val value: UByte?) : BatPercentRemainingAttributeSubscriptionState() + data class Error(val exception: Exception) : BatPercentRemainingAttributeSubscriptionState() - object SubscriptionEstablished : BatPercentRemainingAttributeSubscriptionState() - } -class BatTimeRemainingAttribute( - val value: UInt? - ) + object SubscriptionEstablished : BatPercentRemainingAttributeSubscriptionState() + } + + class BatTimeRemainingAttribute(val value: UInt?) sealed class BatTimeRemainingAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BatTimeRemainingAttributeSubscriptionState() - + data class Success(val value: UInt?) : BatTimeRemainingAttributeSubscriptionState() + data class Error(val exception: Exception) : BatTimeRemainingAttributeSubscriptionState() - object SubscriptionEstablished : BatTimeRemainingAttributeSubscriptionState() - } -class ActiveBatFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : BatTimeRemainingAttributeSubscriptionState() + } + + class ActiveBatFaultsAttribute(val value: List?) sealed class ActiveBatFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveBatFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveBatFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveBatFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveBatFaultsAttributeSubscriptionState() - } -class BatTimeToFullChargeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : ActiveBatFaultsAttributeSubscriptionState() + } + + class BatTimeToFullChargeAttribute(val value: UInt?) sealed class BatTimeToFullChargeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BatTimeToFullChargeAttributeSubscriptionState() - + data class Success(val value: UInt?) : BatTimeToFullChargeAttributeSubscriptionState() + data class Error(val exception: Exception) : BatTimeToFullChargeAttributeSubscriptionState() - object SubscriptionEstablished : BatTimeToFullChargeAttributeSubscriptionState() - } -class BatChargingCurrentAttribute( - val value: UInt? - ) + object SubscriptionEstablished : BatTimeToFullChargeAttributeSubscriptionState() + } + + class BatChargingCurrentAttribute(val value: UInt?) sealed class BatChargingCurrentAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BatChargingCurrentAttributeSubscriptionState() - + data class Success(val value: UInt?) : BatChargingCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : BatChargingCurrentAttributeSubscriptionState() - object SubscriptionEstablished : BatChargingCurrentAttributeSubscriptionState() - } -class ActiveBatChargeFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : BatChargingCurrentAttributeSubscriptionState() + } + + class ActiveBatChargeFaultsAttribute(val value: List?) sealed class ActiveBatChargeFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveBatChargeFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveBatChargeFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveBatChargeFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveBatChargeFaultsAttributeSubscriptionState() - } -class EndpointListAttribute( - val value: List - ) + object SubscriptionEstablished : ActiveBatChargeFaultsAttributeSubscriptionState() + } + + class EndpointListAttribute(val value: List) sealed class EndpointListAttributeSubscriptionState { - data class Success( - val value: List - ) : EndpointListAttributeSubscriptionState() - + data class Success(val value: List) : EndpointListAttributeSubscriptionState() + data class Error(val exception: Exception) : EndpointListAttributeSubscriptionState() - object SubscriptionEstablished : EndpointListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : EndpointListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Status attribute not found in response" - } + } + + requireNotNull(attributeData) { "Status attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -311,35 +237,37 @@ suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Status attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Status attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -351,44 +279,37 @@ suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOrderAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOrderAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Order attribute not found in response" - } + } + + requireNotNull(attributeData) { "Order attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -397,35 +318,37 @@ suspend fun readOrderAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Order attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Order attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -437,44 +360,37 @@ suspend fun readOrderAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDescriptionAttribute(): String { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in response" - } + } + + requireNotNull(attributeData) { "Description attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -483,35 +399,37 @@ suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Description attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -523,52 +441,46 @@ suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 2u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedinputvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredassessedinputvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return WiredAssessedInputVoltageAttribute(decodedValue) } @@ -578,104 +490,102 @@ suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageA maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WiredAssessedInputVoltageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WiredAssessedInputVoltageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedinputvoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredassessedinputvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(WiredAssessedInputVoltageAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(WiredAssessedInputVoltageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFrequencyAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFrequencyAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedinputfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredassessedinputfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return WiredAssessedInputFrequencyAttribute(decodedValue) } @@ -685,99 +595,97 @@ suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFreque maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WiredAssessedInputFrequencyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WiredAssessedInputFrequencyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedinputfrequency attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredassessedinputfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(WiredAssessedInputFrequencyAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(WiredAssessedInputFrequencyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredCurrentTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredCurrentTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredcurrenttype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredcurrenttype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -787,99 +695,95 @@ suspend fun readWiredCurrentTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredcurrenttype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredcurrenttype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredassessedcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return WiredAssessedCurrentAttribute(decodedValue) } @@ -889,99 +793,95 @@ suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WiredAssessedCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WiredAssessedCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredassessedcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(WiredAssessedCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(WiredAssessedCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(WiredAssessedCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredNominalVoltageAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredNominalVoltageAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wirednominalvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wirednominalvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -991,94 +891,90 @@ suspend fun readWiredNominalVoltageAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wirednominalvoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wirednominalvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredMaximumCurrentAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredMaximumCurrentAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredmaximumcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredmaximumcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -1088,94 +984,90 @@ suspend fun readWiredMaximumCurrentAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredmaximumcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredmaximumcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredPresentAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredpresent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredpresent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1185,100 +1077,94 @@ suspend fun readWiredPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredpresent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Wiredpresent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activewiredfaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activewiredfaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveWiredFaultsAttribute(decodedValue) } @@ -1288,105 +1174,101 @@ suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveWiredFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveWiredFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activewiredfaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activewiredfaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveWiredFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveWiredFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveWiredFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatVoltageAttribute(): BatVoltageAttribute {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatVoltageAttribute(): BatVoltageAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatVoltageAttribute(decodedValue) } @@ -1396,104 +1278,98 @@ suspend fun readBatVoltageAttribute(): BatVoltageAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatVoltageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatVoltageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batvoltage attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatVoltageAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatVoltageAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatVoltageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batpercentremaining attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batpercentremaining attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatPercentRemainingAttribute(decodedValue) } @@ -1503,104 +1379,100 @@ suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatPercentRemainingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatPercentRemainingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batpercentremaining attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batpercentremaining attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatPercentRemainingAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatPercentRemainingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatPercentRemainingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Battimeremaining attribute not found in response" - } + } + + requireNotNull(attributeData) { "Battimeremaining attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatTimeRemainingAttribute(decodedValue) } @@ -1610,99 +1482,95 @@ suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatTimeRemainingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatTimeRemainingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Battimeremaining attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Battimeremaining attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatTimeRemainingAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatTimeRemainingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatTimeRemainingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatChargeLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatChargeLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargelevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batchargelevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1712,94 +1580,90 @@ suspend fun readBatChargeLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 14u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargelevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batchargelevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatReplacementNeededAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatReplacementNeededAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplacementneeded attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batreplacementneeded attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1809,94 +1673,90 @@ suspend fun readBatReplacementNeededAttribute(): Boolean? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplacementneeded attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batreplacementneeded attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatReplaceabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatReplaceabilityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplaceability attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batreplaceability attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1906,94 +1766,90 @@ suspend fun readBatReplaceabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplaceability attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batreplaceability attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatPresentAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batpresent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batpresent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -2003,100 +1859,94 @@ suspend fun readBatPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batpresent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batpresent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activebatfaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activebatfaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveBatFaultsAttribute(decodedValue) } @@ -2106,100 +1956,96 @@ suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveBatFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveBatFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activebatfaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activebatfaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveBatFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveBatFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveBatFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatReplacementDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatReplacementDescriptionAttribute(): String? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplacementdescription attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batreplacementdescription attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -2209,94 +2055,90 @@ suspend fun readBatReplacementDescriptionAttribute(): String? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplacementdescription attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batreplacementdescription attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatCommonDesignationAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatCommonDesignationAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batcommondesignation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batcommondesignation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2306,94 +2148,90 @@ suspend fun readBatCommonDesignationAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batcommondesignation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batcommondesignation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatANSIDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatANSIDesignationAttribute(): String? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batansidesignation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batansidesignation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -2403,94 +2241,90 @@ suspend fun readBatANSIDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batansidesignation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batansidesignation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatIECDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatIECDesignationAttribute(): String? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batiecdesignation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batiecdesignation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -2500,94 +2334,90 @@ suspend fun readBatIECDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batiecdesignation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batiecdesignation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatApprovedChemistryAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatApprovedChemistryAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batapprovedchemistry attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batapprovedchemistry attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2597,94 +2427,90 @@ suspend fun readBatApprovedChemistryAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batapprovedchemistry attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batapprovedchemistry attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatCapacityAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatCapacityAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batcapacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batcapacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2694,94 +2520,88 @@ suspend fun readBatCapacityAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batcapacity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batcapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatQuantityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatQuantityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batquantity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batquantity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2791,94 +2611,88 @@ suspend fun readBatQuantityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 25u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batquantity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batquantity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatChargeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatChargeStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargestate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batchargestate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2888,99 +2702,95 @@ suspend fun readBatChargeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargestate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batchargestate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Battimetofullcharge attribute not found in response" - } + } + + requireNotNull(attributeData) { "Battimetofullcharge attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatTimeToFullChargeAttribute(decodedValue) } @@ -2990,99 +2800,95 @@ suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatTimeToFullChargeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatTimeToFullChargeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Battimetofullcharge attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Battimetofullcharge attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatTimeToFullChargeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatTimeToFullChargeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatTimeToFullChargeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatFunctionalWhileChargingAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatFunctionalWhileChargingAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batfunctionalwhilecharging attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batfunctionalwhilecharging attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -3092,99 +2898,95 @@ suspend fun readBatFunctionalWhileChargingAttribute(): Boolean? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batfunctionalwhilecharging attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batfunctionalwhilecharging attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute {val ATTRIBUTE_ID: UInt = 29u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute { + val ATTRIBUTE_ID: UInt = 29u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargingcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batchargingcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatChargingCurrentAttribute(decodedValue) } @@ -3194,105 +2996,101 @@ suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 29u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatChargingCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatChargingCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargingcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batchargingcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatChargingCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatChargingCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatChargingCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute {val ATTRIBUTE_ID: UInt = 30u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activebatchargefaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activebatchargefaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveBatChargeFaultsAttribute(decodedValue) } @@ -3302,102 +3100,98 @@ suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveBatChargeFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveBatChargeFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activebatchargefaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activebatchargefaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveBatChargeFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveBatChargeFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveBatChargeFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEndpointListAttribute(): EndpointListAttribute {val ATTRIBUTE_ID: UInt = 31u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEndpointListAttribute(): EndpointListAttribute { + val ATTRIBUTE_ID: UInt = 31u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endpointlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Endpointlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EndpointListAttribute(decodedValue) } @@ -3407,45 +3201,48 @@ suspend fun readEndpointListAttribute(): EndpointListAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 31u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EndpointListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EndpointListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endpointlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Endpointlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EndpointListAttributeSubscriptionState.Success(decodedValue)) } @@ -3453,49 +3250,43 @@ suspend fun readEndpointListAttribute(): EndpointListAttribute {val ATTRIBUTE_ID emit(EndpointListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -3505,45 +3296,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3551,49 +3347,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -3603,45 +3393,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3649,49 +3444,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -3701,45 +3490,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -3747,49 +3539,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -3799,45 +3585,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -3845,44 +3634,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -3891,35 +3673,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3931,44 +3715,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -3977,34 +3754,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -4017,7 +3798,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt index 59bfeff63ee455..eb3b505f117912 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt @@ -17,154 +17,111 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class PowerSourceConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class SourcesAttribute( - val value: List - ) +class PowerSourceConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SourcesAttribute(val value: List) sealed class SourcesAttributeSubscriptionState { - data class Success( - val value: List - ) : SourcesAttributeSubscriptionState() - + data class Success(val value: List) : SourcesAttributeSubscriptionState() + data class Error(val exception: Exception) : SourcesAttributeSubscriptionState() - object SubscriptionEstablished : SourcesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SourcesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSourcesAttribute(): SourcesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSourcesAttribute(): SourcesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sources attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sources attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SourcesAttribute(decodedValue) } @@ -174,45 +131,48 @@ suspend fun readSourcesAttribute(): SourcesAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SourcesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SourcesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sources attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Sources attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(SourcesAttributeSubscriptionState.Success(decodedValue)) } @@ -220,49 +180,43 @@ suspend fun readSourcesAttribute(): SourcesAttribute {val ATTRIBUTE_ID: UInt = 0 emit(SourcesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -272,45 +226,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -318,49 +277,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -370,45 +323,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -416,49 +374,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -468,45 +420,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -514,49 +469,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -566,45 +515,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -612,44 +564,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -658,35 +603,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -698,44 +645,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -744,34 +684,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -784,7 +728,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerTopologyCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerTopologyCluster.kt index 2555983a6cc8b5..763677bae3dee5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerTopologyCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerTopologyCluster.kt @@ -17,171 +17,125 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class PowerTopologyCluster(private val controller: MatterController, private val endpointId: UShort) {class AvailableEndpointsAttribute( - val value: List? - ) +class PowerTopologyCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AvailableEndpointsAttribute(val value: List?) sealed class AvailableEndpointsAttributeSubscriptionState { - data class Success( - val value: List? - ) : AvailableEndpointsAttributeSubscriptionState() - + data class Success(val value: List?) : AvailableEndpointsAttributeSubscriptionState() + data class Error(val exception: Exception) : AvailableEndpointsAttributeSubscriptionState() - object SubscriptionEstablished : AvailableEndpointsAttributeSubscriptionState() - } -class ActiveEndpointsAttribute( - val value: List? - ) + object SubscriptionEstablished : AvailableEndpointsAttributeSubscriptionState() + } + + class ActiveEndpointsAttribute(val value: List?) sealed class ActiveEndpointsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveEndpointsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveEndpointsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveEndpointsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveEndpointsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ActiveEndpointsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readAvailableEndpointsAttribute(): AvailableEndpointsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readAvailableEndpointsAttribute(): AvailableEndpointsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availableendpoints attribute not found in response" - } + } + + requireNotNull(attributeData) { "Availableendpoints attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return AvailableEndpointsAttribute(decodedValue) } @@ -191,106 +145,102 @@ suspend fun readAvailableEndpointsAttribute(): AvailableEndpointsAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AvailableEndpointsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AvailableEndpointsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availableendpoints attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Availableendpoints attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(AvailableEndpointsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(AvailableEndpointsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AvailableEndpointsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveEndpointsAttribute(): ActiveEndpointsAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveEndpointsAttribute(): ActiveEndpointsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeendpoints attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activeendpoints attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveEndpointsAttribute(decodedValue) } @@ -300,102 +250,98 @@ suspend fun readActiveEndpointsAttribute(): ActiveEndpointsAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveEndpointsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveEndpointsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeendpoints attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activeendpoints attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveEndpointsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveEndpointsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveEndpointsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -405,45 +351,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -451,49 +402,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -503,45 +448,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -549,49 +499,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -601,45 +545,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -647,49 +594,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -699,45 +640,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -745,44 +689,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -791,35 +728,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -831,44 +770,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -877,34 +809,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -917,7 +853,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt index e8726e5f3a3cac..e374599a909987 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt @@ -17,218 +17,161 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.ByteSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class PressureMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Short? - ) +class PressureMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Short?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Short?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Short?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class ScaledValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class ScaledValueAttribute(val value: Short?) sealed class ScaledValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : ScaledValueAttributeSubscriptionState() - + data class Success(val value: Short?) : ScaledValueAttributeSubscriptionState() + data class Error(val exception: Exception) : ScaledValueAttributeSubscriptionState() - object SubscriptionEstablished : ScaledValueAttributeSubscriptionState() - } -class MinScaledValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : ScaledValueAttributeSubscriptionState() + } + + class MinScaledValueAttribute(val value: Short?) sealed class MinScaledValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinScaledValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MinScaledValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinScaledValueAttributeSubscriptionState() - object SubscriptionEstablished : MinScaledValueAttributeSubscriptionState() - } -class MaxScaledValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinScaledValueAttributeSubscriptionState() + } + + class MaxScaledValueAttribute(val value: Short?) sealed class MaxScaledValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxScaledValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxScaledValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxScaledValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxScaledValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : MaxScaledValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -238,96 +181,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -337,96 +274,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -436,95 +369,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -534,99 +463,93 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScaledValueAttribute(): ScaledValueAttribute {val ATTRIBUTE_ID: UInt = 16u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScaledValueAttribute(): ScaledValueAttribute { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scaledvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scaledvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ScaledValueAttribute(decodedValue) } @@ -636,104 +559,98 @@ suspend fun readScaledValueAttribute(): ScaledValueAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ScaledValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ScaledValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scaledvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Scaledvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ScaledValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ScaledValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ScaledValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute {val ATTRIBUTE_ID: UInt = 17u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minscaledvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minscaledvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinScaledValueAttribute(decodedValue) } @@ -743,104 +660,100 @@ suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinScaledValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinScaledValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minscaledvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minscaledvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinScaledValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinScaledValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinScaledValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute {val ATTRIBUTE_ID: UInt = 18u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxscaledvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxscaledvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxScaledValueAttribute(decodedValue) } @@ -850,99 +763,95 @@ suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxScaledValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxScaledValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxscaledvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxscaledvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxScaledValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxScaledValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxScaledValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScaledToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScaledToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scaledtolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scaledtolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -952,94 +861,90 @@ suspend fun readScaledToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scaledtolerance attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scaledtolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScaleAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 20u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScaleAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scale attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scale attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1049,96 +954,90 @@ suspend fun readScaleAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 20u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scale attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Scale attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1148,45 +1047,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1194,49 +1098,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1246,45 +1144,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1292,49 +1195,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1344,45 +1241,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1390,49 +1290,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1442,45 +1336,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1488,44 +1385,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1534,35 +1424,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1574,44 +1466,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1620,34 +1505,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1660,7 +1549,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt index b08df6933b9fd1..5eb0f105ba47d1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt @@ -17,141 +17,101 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ProxyConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ProxyConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -161,45 +121,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -207,49 +172,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -259,45 +218,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -305,49 +269,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -357,45 +315,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -403,49 +364,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -455,45 +410,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -501,44 +459,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -547,35 +498,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -587,44 +540,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -633,34 +579,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -673,7 +623,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt index 42d50e762f785c..46ad79a25cd0c2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt @@ -17,141 +17,101 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ProxyDiscoveryCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ProxyDiscoveryCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -161,45 +121,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -207,49 +172,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -259,45 +218,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -305,49 +269,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -357,45 +315,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -403,49 +364,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -455,45 +410,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -501,44 +459,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -547,35 +498,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -587,44 +540,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -633,34 +579,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -673,7 +623,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt index 79217bb65e2c72..96d846ad277cec 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt @@ -17,141 +17,98 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ProxyValidCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ProxyValidCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -161,45 +118,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -207,49 +169,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -259,45 +215,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -305,49 +266,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -357,45 +312,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -403,49 +361,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -455,45 +407,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -501,44 +456,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -547,35 +495,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -587,44 +537,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -633,34 +576,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -673,7 +620,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt index 0ae147a5169862..0e2ffc820350d9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt @@ -17,141 +17,101 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class PulseWidthModulationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class PulseWidthModulationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -161,45 +121,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -207,49 +172,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -259,45 +218,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -305,49 +269,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -357,45 +315,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -403,49 +364,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -455,45 +410,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -501,44 +459,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -547,35 +498,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -587,44 +540,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -633,34 +579,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -673,7 +623,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt index 77f27057b0a555..6620523d5be3fa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt @@ -17,374 +17,285 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PumpConfigurationAndControlCluster(private val controller: MatterController, private val endpointId: UShort) {class MaxPressureAttribute( - val value: Short? - ) +class PumpConfigurationAndControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MaxPressureAttribute(val value: Short?) sealed class MaxPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxPressureAttributeSubscriptionState() - object SubscriptionEstablished : MaxPressureAttributeSubscriptionState() - } -class MaxSpeedAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MaxPressureAttributeSubscriptionState() + } + + class MaxSpeedAttribute(val value: UShort?) sealed class MaxSpeedAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxSpeedAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxSpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxSpeedAttributeSubscriptionState() - object SubscriptionEstablished : MaxSpeedAttributeSubscriptionState() - } -class MaxFlowAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MaxSpeedAttributeSubscriptionState() + } + + class MaxFlowAttribute(val value: UShort?) sealed class MaxFlowAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxFlowAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxFlowAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxFlowAttributeSubscriptionState() - object SubscriptionEstablished : MaxFlowAttributeSubscriptionState() - } -class MinConstPressureAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxFlowAttributeSubscriptionState() + } + + class MinConstPressureAttribute(val value: Short?) sealed class MinConstPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinConstPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MinConstPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstPressureAttributeSubscriptionState() - object SubscriptionEstablished : MinConstPressureAttributeSubscriptionState() - } -class MaxConstPressureAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinConstPressureAttributeSubscriptionState() + } + + class MaxConstPressureAttribute(val value: Short?) sealed class MaxConstPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxConstPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxConstPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstPressureAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstPressureAttributeSubscriptionState() - } -class MinCompPressureAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxConstPressureAttributeSubscriptionState() + } + + class MinCompPressureAttribute(val value: Short?) sealed class MinCompPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinCompPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MinCompPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MinCompPressureAttributeSubscriptionState() - object SubscriptionEstablished : MinCompPressureAttributeSubscriptionState() - } -class MaxCompPressureAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinCompPressureAttributeSubscriptionState() + } + + class MaxCompPressureAttribute(val value: Short?) sealed class MaxCompPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxCompPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxCompPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxCompPressureAttributeSubscriptionState() - object SubscriptionEstablished : MaxCompPressureAttributeSubscriptionState() - } -class MinConstSpeedAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MaxCompPressureAttributeSubscriptionState() + } + + class MinConstSpeedAttribute(val value: UShort?) sealed class MinConstSpeedAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinConstSpeedAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinConstSpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstSpeedAttributeSubscriptionState() - object SubscriptionEstablished : MinConstSpeedAttributeSubscriptionState() - } -class MaxConstSpeedAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinConstSpeedAttributeSubscriptionState() + } + + class MaxConstSpeedAttribute(val value: UShort?) sealed class MaxConstSpeedAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxConstSpeedAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxConstSpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstSpeedAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstSpeedAttributeSubscriptionState() - } -class MinConstFlowAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MaxConstSpeedAttributeSubscriptionState() + } + + class MinConstFlowAttribute(val value: UShort?) sealed class MinConstFlowAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinConstFlowAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinConstFlowAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstFlowAttributeSubscriptionState() - object SubscriptionEstablished : MinConstFlowAttributeSubscriptionState() - } -class MaxConstFlowAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinConstFlowAttributeSubscriptionState() + } + + class MaxConstFlowAttribute(val value: UShort?) sealed class MaxConstFlowAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxConstFlowAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxConstFlowAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstFlowAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstFlowAttributeSubscriptionState() - } -class MinConstTempAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxConstFlowAttributeSubscriptionState() + } + + class MinConstTempAttribute(val value: Short?) sealed class MinConstTempAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinConstTempAttributeSubscriptionState() - + data class Success(val value: Short?) : MinConstTempAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstTempAttributeSubscriptionState() - object SubscriptionEstablished : MinConstTempAttributeSubscriptionState() - } -class MaxConstTempAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinConstTempAttributeSubscriptionState() + } + + class MaxConstTempAttribute(val value: Short?) sealed class MaxConstTempAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxConstTempAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxConstTempAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstTempAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstTempAttributeSubscriptionState() - } -class CapacityAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxConstTempAttributeSubscriptionState() + } + + class CapacityAttribute(val value: Short?) sealed class CapacityAttributeSubscriptionState { - data class Success( - val value: Short? - ) : CapacityAttributeSubscriptionState() - + data class Success(val value: Short?) : CapacityAttributeSubscriptionState() + data class Error(val exception: Exception) : CapacityAttributeSubscriptionState() - object SubscriptionEstablished : CapacityAttributeSubscriptionState() - } -class SpeedAttribute( - val value: UShort? - ) + object SubscriptionEstablished : CapacityAttributeSubscriptionState() + } + + class SpeedAttribute(val value: UShort?) sealed class SpeedAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : SpeedAttributeSubscriptionState() - + data class Success(val value: UShort?) : SpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : SpeedAttributeSubscriptionState() - object SubscriptionEstablished : SpeedAttributeSubscriptionState() - } -class LifetimeRunningHoursAttribute( - val value: UInt? - ) + object SubscriptionEstablished : SpeedAttributeSubscriptionState() + } + + class LifetimeRunningHoursAttribute(val value: UInt?) sealed class LifetimeRunningHoursAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LifetimeRunningHoursAttributeSubscriptionState() - + data class Success(val value: UInt?) : LifetimeRunningHoursAttributeSubscriptionState() + data class Error(val exception: Exception) : LifetimeRunningHoursAttributeSubscriptionState() - object SubscriptionEstablished : LifetimeRunningHoursAttributeSubscriptionState() - } -class PowerAttribute( - val value: UInt? - ) + object SubscriptionEstablished : LifetimeRunningHoursAttributeSubscriptionState() + } + + class PowerAttribute(val value: UInt?) sealed class PowerAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PowerAttributeSubscriptionState() - + data class Success(val value: UInt?) : PowerAttributeSubscriptionState() + data class Error(val exception: Exception) : PowerAttributeSubscriptionState() - object SubscriptionEstablished : PowerAttributeSubscriptionState() - } -class LifetimeEnergyConsumedAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PowerAttributeSubscriptionState() + } + + class LifetimeEnergyConsumedAttribute(val value: UInt?) sealed class LifetimeEnergyConsumedAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LifetimeEnergyConsumedAttributeSubscriptionState() - + data class Success(val value: UInt?) : LifetimeEnergyConsumedAttributeSubscriptionState() + data class Error(val exception: Exception) : LifetimeEnergyConsumedAttributeSubscriptionState() - object SubscriptionEstablished : LifetimeEnergyConsumedAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LifetimeEnergyConsumedAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMaxPressureAttribute(): MaxPressureAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMaxPressureAttribute(): MaxPressureAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxpressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxPressureAttribute(decodedValue) } @@ -394,96 +305,90 @@ suspend fun readMaxPressureAttribute(): MaxPressureAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpressure attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxpressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(MaxPressureAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(MaxPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxspeed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxspeed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxSpeedAttribute(decodedValue) } @@ -493,96 +398,90 @@ suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxSpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxSpeedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxspeed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxspeed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(MaxSpeedAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(MaxSpeedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxSpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxFlowAttribute(): MaxFlowAttribute {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxFlowAttribute(): MaxFlowAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxflow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxflow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxFlowAttribute(decodedValue) } @@ -592,100 +491,94 @@ suspend fun readMaxFlowAttribute(): MaxFlowAttribute {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxFlowAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxFlowAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxflow attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxflow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(MaxFlowAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(MaxFlowAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxFlowAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstpressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minconstpressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinConstPressureAttribute(decodedValue) } @@ -695,104 +588,100 @@ suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinConstPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinConstPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstpressure attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minconstpressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinConstPressureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinConstPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinConstPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstpressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxconstpressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxConstPressureAttribute(decodedValue) } @@ -802,104 +691,100 @@ suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxConstPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxConstPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstpressure attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxconstpressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxConstPressureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxConstPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mincomppressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mincomppressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinCompPressureAttribute(decodedValue) } @@ -909,104 +794,100 @@ suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinCompPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinCompPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mincomppressure attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Mincomppressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinCompPressureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinCompPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinCompPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcomppressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxcomppressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxCompPressureAttribute(decodedValue) } @@ -1016,104 +897,100 @@ suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxCompPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxCompPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcomppressure attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxcomppressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxCompPressureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxCompPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxCompPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstspeed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minconstspeed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinConstSpeedAttribute(decodedValue) } @@ -1123,104 +1000,98 @@ suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinConstSpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinConstSpeedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstspeed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minconstspeed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinConstSpeedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinConstSpeedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinConstSpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstspeed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxconstspeed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxConstSpeedAttribute(decodedValue) } @@ -1230,104 +1101,98 @@ suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxConstSpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxConstSpeedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstspeed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxconstspeed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxConstSpeedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxConstSpeedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstSpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstflow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minconstflow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinConstFlowAttribute(decodedValue) } @@ -1337,104 +1202,98 @@ suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinConstFlowAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinConstFlowAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstflow attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minconstflow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinConstFlowAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinConstFlowAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinConstFlowAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstflow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxconstflow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxConstFlowAttribute(decodedValue) } @@ -1444,104 +1303,98 @@ suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxConstFlowAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxConstFlowAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstflow attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxconstflow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxConstFlowAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxConstFlowAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstFlowAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinConstTempAttribute(): MinConstTempAttribute {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinConstTempAttribute(): MinConstTempAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconsttemp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minconsttemp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinConstTempAttribute(decodedValue) } @@ -1551,104 +1404,98 @@ suspend fun readMinConstTempAttribute(): MinConstTempAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinConstTempAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinConstTempAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconsttemp attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minconsttemp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinConstTempAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinConstTempAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinConstTempAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconsttemp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxconsttemp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxConstTempAttribute(decodedValue) } @@ -1658,99 +1505,93 @@ suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxConstTempAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxConstTempAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconsttemp attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxconsttemp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxConstTempAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxConstTempAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstTempAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPumpStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPumpStatusAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pumpstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Pumpstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1760,91 +1601,84 @@ suspend fun readPumpStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pumpstatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Pumpstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEffectiveOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEffectiveOperationModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Effectiveoperationmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Effectiveoperationmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1853,34 +1687,38 @@ suspend fun readEffectiveOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Effectiveoperationmode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Effectiveoperationmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1893,44 +1731,37 @@ suspend fun readEffectiveOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEffectiveControlModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEffectiveControlModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Effectivecontrolmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Effectivecontrolmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1939,34 +1770,38 @@ suspend fun readEffectiveControlModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Effectivecontrolmode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Effectivecontrolmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1979,48 +1814,42 @@ suspend fun readEffectiveControlModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCapacityAttribute(): CapacityAttribute {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCapacityAttribute(): CapacityAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Capacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Capacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CapacityAttribute(decodedValue) } @@ -2030,100 +1859,94 @@ suspend fun readCapacityAttribute(): CapacityAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CapacityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CapacityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Capacity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Capacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(CapacityAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(CapacityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CapacityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpeedAttribute(): SpeedAttribute {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSpeedAttribute(): SpeedAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Speed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SpeedAttribute(decodedValue) } @@ -2133,128 +1956,118 @@ suspend fun readSpeedAttribute(): SpeedAttribute {val ATTRIBUTE_ID: UInt = 20u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SpeedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Speed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SpeedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SpeedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lifetimerunninghours attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lifetimerunninghours attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LifetimeRunningHoursAttribute(decodedValue) } - suspend fun writeLifetimeRunningHoursAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLifetimeRunningHoursAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2276,7 +2089,7 @@ suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLifetimeRunningHoursAttribute( @@ -2284,104 +2097,100 @@ suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LifetimeRunningHoursAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LifetimeRunningHoursAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lifetimerunninghours attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lifetimerunninghours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LifetimeRunningHoursAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LifetimeRunningHoursAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LifetimeRunningHoursAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerAttribute(): PowerAttribute {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerAttribute(): PowerAttribute { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Power attribute not found in response" - } + } + + requireNotNull(attributeData) { "Power attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PowerAttribute(decodedValue) } @@ -2391,128 +2200,121 @@ suspend fun readPowerAttribute(): PowerAttribute {val ATTRIBUTE_ID: UInt = 22u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PowerAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Power attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Power attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PowerAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PowerAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PowerAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribute {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribute { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lifetimeenergyconsumed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lifetimeenergyconsumed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LifetimeEnergyConsumedAttribute(decodedValue) } suspend fun writeLifetimeEnergyConsumedAttribute( value: UInt, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2534,7 +2336,7 @@ suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribu throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLifetimeEnergyConsumedAttribute( @@ -2542,119 +2344,110 @@ suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LifetimeEnergyConsumedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LifetimeEnergyConsumedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lifetimeenergyconsumed attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lifetimeenergyconsumed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LifetimeEnergyConsumedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LifetimeEnergyConsumedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LifetimeEnergyConsumedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOperationModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeOperationModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOperationModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 32u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2676,7 +2469,7 @@ suspend fun readOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOperationModeAttribute( @@ -2684,35 +2477,37 @@ suspend fun readOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Operationmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2724,71 +2519,61 @@ suspend fun readOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readControlModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readControlModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Controlmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Controlmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeControlModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeControlModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2810,7 +2595,7 @@ suspend fun readControlModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeControlModeAttribute( @@ -2818,96 +2603,90 @@ suspend fun readControlModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Controlmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Controlmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2917,45 +2696,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2963,49 +2747,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -3015,45 +2793,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3061,49 +2844,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -3113,45 +2890,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -3159,49 +2939,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -3211,45 +2985,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -3257,44 +3034,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -3303,35 +3073,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3343,44 +3115,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -3389,34 +3154,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3429,7 +3198,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt index 05e3ef50cbd96d..d2d71369780de0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class RadonConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class RadonConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt index fc8ca10f3d18d2..70eb72e6db7ec9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt @@ -17,136 +17,95 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class RefrigeratorAlarmCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class RefrigeratorAlarmCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMaskAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -155,35 +114,37 @@ suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mask attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Mask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,44 +156,37 @@ suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStateAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in response" - } + } + + requireNotNull(attributeData) { "State attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -241,35 +195,37 @@ suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "State attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -281,44 +237,37 @@ suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -327,35 +276,37 @@ suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supported attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Supported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -367,49 +318,43 @@ suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -419,45 +364,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -465,49 +415,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -517,45 +461,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -563,49 +512,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -615,45 +558,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -661,49 +607,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -713,45 +653,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -759,44 +702,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -805,35 +741,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -845,44 +783,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -891,34 +822,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -931,7 +866,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt index ce6565c3397935..61898b4f3d849d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt @@ -17,154 +17,123 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RefrigeratorAndTemperatureControlledCabinetModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( +class RefrigeratorAndTemperatureControlledCabinetModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute( val value: List ) sealed class SupportedModesAttributeSubscriptionState { data class Success( - val value: List + val value: List ) : SupportedModesAttributeSubscriptionState() - + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +150,82 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +235,56 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: + List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +292,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +331,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +373,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +454,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +462,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +595,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +603,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +701,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +752,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +798,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +849,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +895,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +944,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +990,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1039,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1078,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1120,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1159,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,11 +1203,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(RefrigeratorAndTemperatureControlledCabinetModeCluster::class.java.name) + private val logger = + Logger.getLogger(RefrigeratorAndTemperatureControlledCabinetModeCluster::class.java.name) const val CLUSTER_ID: UInt = 82u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt index c7f6f1f5cc66a8..c8b35042a38183 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt @@ -17,179 +17,130 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class RelativeHumidityMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: UShort? - ) +class RelativeHumidityMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: UShort?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: UShort?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: UShort?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -199,96 +150,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -298,96 +243,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -397,95 +338,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -495,96 +432,90 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -594,45 +525,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -640,49 +576,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -692,45 +622,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -738,49 +673,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -790,45 +719,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -836,49 +768,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -888,45 +814,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -934,44 +863,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -980,35 +902,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1020,44 +944,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1066,34 +983,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1106,7 +1027,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt index 7ac51acbac5c46..cf21074dc5fefb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt @@ -17,128 +17,97 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcCleanModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) +class RvcCleanModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,92 +124,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -250,45 +204,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -296,44 +255,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -342,35 +294,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -382,49 +336,43 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -434,45 +382,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -480,49 +433,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -532,45 +479,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -578,49 +530,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -630,45 +576,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -676,49 +625,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -728,45 +671,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -774,44 +720,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -820,35 +759,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -860,44 +801,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -906,34 +840,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -946,7 +884,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt index 87da9febd27bcd..3c46632bac37f1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt @@ -17,175 +17,136 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcOperationalStateCluster(private val controller: MatterController, private val endpointId: UShort) { +class RvcOperationalStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class OperationalCommandResponse( val commandResponseState: RvcOperationalStateClusterErrorStateStruct ) -class PhaseListAttribute( - val value: List? - ) + + class PhaseListAttribute(val value: List?) sealed class PhaseListAttributeSubscriptionState { - data class Success( - val value: List? - ) : PhaseListAttributeSubscriptionState() - + data class Success(val value: List?) : PhaseListAttributeSubscriptionState() + data class Error(val exception: Exception) : PhaseListAttributeSubscriptionState() - object SubscriptionEstablished : PhaseListAttributeSubscriptionState() - } -class CurrentPhaseAttribute( - val value: UByte? - ) + object SubscriptionEstablished : PhaseListAttributeSubscriptionState() + } + + class CurrentPhaseAttribute(val value: UByte?) sealed class CurrentPhaseAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPhaseAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentPhaseAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPhaseAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() - } -class CountdownTimeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() + } + + class CountdownTimeAttribute(val value: UInt?) sealed class CountdownTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : CountdownTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : CountdownTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : CountdownTimeAttributeSubscriptionState() - object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() - } -class OperationalStateListAttribute( + object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() + } + + class OperationalStateListAttribute( val value: List ) sealed class OperationalStateListAttributeSubscriptionState { - data class Success( - val value: List - ) : OperationalStateListAttributeSubscriptionState() - + data class Success(val value: List) : + OperationalStateListAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalStateListAttributeSubscriptionState() - object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() - } -class OperationalErrorAttribute( - val value: RvcOperationalStateClusterErrorStateStruct - ) + object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() + } + + class OperationalErrorAttribute(val value: RvcOperationalStateClusterErrorStateStruct) sealed class OperationalErrorAttributeSubscriptionState { - data class Success( - val value: RvcOperationalStateClusterErrorStateStruct - ) : OperationalErrorAttributeSubscriptionState() - + data class Success(val value: RvcOperationalStateClusterErrorStateStruct) : + OperationalErrorAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalErrorAttributeSubscriptionState() - object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun pause(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -202,39 +163,32 @@ class AttributeListAttribute( 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 { + 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") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -251,39 +205,32 @@ class AttributeListAttribute( 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 { + 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") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun goHome(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 128u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -300,79 +247,66 @@ class AttributeListAttribute( 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 { + 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") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } -suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhaseListAttribute(): PhaseListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Phaselist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return PhaseListAttribute(decodedValue) } @@ -382,102 +316,96 @@ suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PhaseListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PhaseListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Phaselist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PhaseListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PhaseListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PhaseListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentphase attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPhaseAttribute(decodedValue) } @@ -487,100 +415,94 @@ suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPhaseAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPhaseAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentphase attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPhaseAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPhaseAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPhaseAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Countdowntime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CountdownTimeAttribute(decodedValue) } @@ -590,101 +512,95 @@ suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CountdownTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CountdownTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Countdowntime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CountdownTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CountdownTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CountdownTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return OperationalStateListAttribute(decodedValue) } @@ -694,45 +610,52 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalStateListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalStateListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } emit(OperationalStateListAttributeSubscriptionState.Success(decodedValue)) } @@ -740,44 +663,37 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { emit(OperationalStateListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -786,34 +702,38 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -826,43 +746,37 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalerror attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: RvcOperationalStateClusterErrorStateStruct = RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: RvcOperationalStateClusterErrorStateStruct = + RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) return OperationalErrorAttribute(decodedValue) } @@ -872,39 +786,44 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalErrorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalErrorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: RvcOperationalStateClusterErrorStateStruct = RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: RvcOperationalStateClusterErrorStateStruct = + RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) emit(OperationalErrorAttributeSubscriptionState.Success(decodedValue)) } @@ -912,49 +831,43 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR emit(OperationalErrorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -964,45 +877,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1010,49 +928,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1062,45 +974,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1108,49 +1025,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1160,45 +1071,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1206,49 +1120,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1258,45 +1166,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1304,44 +1215,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1350,35 +1254,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1390,44 +1296,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1436,34 +1335,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1476,7 +1379,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt index e1baabf44d5473..05237cd481e136 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt @@ -17,128 +17,94 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class RvcRunModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,92 +121,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -250,45 +201,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -296,44 +252,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -342,35 +291,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -382,49 +333,43 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -434,45 +379,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -480,49 +430,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -532,45 +476,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -578,49 +527,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -630,45 +573,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -676,49 +622,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -728,45 +668,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -774,44 +717,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -820,35 +756,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -860,44 +798,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -906,34 +837,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -946,7 +881,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt index 9d5b10e9a5a6ce..4514121f33fa31 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt @@ -17,110 +17,80 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class SampleMeiCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddArgumentsResponse( - val returnValue: UByte - ) -class GeneratedCommandListAttribute( - val value: List - ) + class AddArgumentsResponse(val returnValue: UByte) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun ping(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,9 +104,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addArguments(arg1: UByte - ,arg2: UByte - ,timedInvokeTimeout: Duration? = null): AddArgumentsResponse { + suspend fun addArguments( + arg1: UByte, + arg2: UByte, + timedInvokeTimeout: Duration? = null + ): AddArgumentsResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -146,7 +118,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) val TAG_ARG2_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) tlvWriter.endStructure() val request: InvokeRequest = @@ -163,92 +135,73 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getUByte(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } - tlvReader.exitContainer() - return AddArgumentsResponse( - returnValue_decoded - ) + return AddArgumentsResponse(returnValue_decoded) } -suspend fun readFlipFlopAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFlipFlopAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Flipflop attribute not found in response" - } + } + + requireNotNull(attributeData) { "Flipflop attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeFlipFlopAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeFlipFlopAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -270,7 +223,7 @@ suspend fun readFlipFlopAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFlipFlopAttribute( @@ -278,35 +231,37 @@ suspend fun readFlipFlopAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Flipflop attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Flipflop attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -318,49 +273,43 @@ suspend fun readFlipFlopAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -370,45 +319,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -416,49 +370,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -468,45 +416,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -514,49 +467,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -566,45 +513,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -612,49 +562,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -664,45 +608,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -710,44 +657,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -756,35 +696,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -796,44 +738,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -842,34 +777,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -882,7 +821,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt index 5af25844a6d2e1..36ad97999c6a6a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt @@ -17,178 +17,131 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ScenesManagementCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte - ) +class ScenesManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AddSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) class ViewSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte, - val transitionTime: UInt?, - val sceneName: String?, + val status: UByte, + val groupID: UShort, + val sceneID: UByte, + val transitionTime: UInt?, + val sceneName: String?, val extensionFieldSets: List? ) - class RemoveSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte - ) + class RemoveSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) - class RemoveAllScenesResponse( - val status: UByte, - val groupID: UShort - ) + class RemoveAllScenesResponse(val status: UByte, val groupID: UShort) - class StoreSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte - ) + class StoreSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) class GetSceneMembershipResponse( - val status: UByte, - val capacity: UByte?, - val groupID: UShort, + val status: UByte, + val capacity: UByte?, + val groupID: UShort, val sceneList: List? ) class CopySceneResponse( - val status: UByte, - val groupIdentifierFrom: UShort, + val status: UByte, + val groupIdentifierFrom: UShort, val sceneIdentifierFrom: UByte ) -class LastConfiguredByAttribute( - val value: ULong? - ) + + class LastConfiguredByAttribute(val value: ULong?) sealed class LastConfiguredByAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : LastConfiguredByAttributeSubscriptionState() - + data class Success(val value: ULong?) : LastConfiguredByAttributeSubscriptionState() + data class Error(val exception: Exception) : LastConfiguredByAttributeSubscriptionState() - object SubscriptionEstablished : LastConfiguredByAttributeSubscriptionState() - } -class FabricSceneInfoAttribute( - val value: List - ) + object SubscriptionEstablished : LastConfiguredByAttributeSubscriptionState() + } + + class FabricSceneInfoAttribute(val value: List) sealed class FabricSceneInfoAttributeSubscriptionState { - data class Success( - val value: List - ) : FabricSceneInfoAttributeSubscriptionState() - + data class Success(val value: List) : + FabricSceneInfoAttributeSubscriptionState() + data class Error(val exception: Exception) : FabricSceneInfoAttributeSubscriptionState() - object SubscriptionEstablished : FabricSceneInfoAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : FabricSceneInfoAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun addScene(groupID: UShort - ,sceneID: UByte - ,transitionTime: UInt - ,sceneName: String - ,extensionFieldSets: List - ,timedInvokeTimeout: Duration? = null): AddSceneResponse { + suspend fun addScene( + groupID: UShort, + sceneID: UByte, + transitionTime: UInt, + sceneName: String, + extensionFieldSets: List, + timedInvokeTimeout: Duration? = null + ): AddSceneResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -208,10 +161,10 @@ class AttributeListAttribute( val TAG_EXTENSION_FIELD_SETS_REQ: Int = 4 tlvWriter.startArray(ContextSpecificTag(TAG_EXTENSION_FIELD_SETS_REQ)) - for (item in extensionFieldSets.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in extensionFieldSets.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -228,59 +181,53 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } - else { + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - tlvReader.exitContainer() - return AddSceneResponse( - status_decoded, - groupID_decoded, - sceneID_decoded - ) + return AddSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) } - suspend fun viewScene(groupID: UShort - ,sceneID: UByte - ,timedInvokeTimeout: Duration? = null): ViewSceneResponse { + suspend fun viewScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeout: Duration? = null + ): ViewSceneResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -290,7 +237,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -307,103 +254,99 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - + val TAG_TRANSITION_TIME: Int = 3 var transitionTime_decoded: UInt? = null - + val TAG_SCENE_NAME: Int = 4 var sceneName_decoded: String? = null - + val TAG_EXTENSION_FIELD_SETS: Int = 5 var extensionFieldSets_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) {transitionTime_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) { + transitionTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_SCENE_NAME)) {sceneName_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SCENE_NAME)) { + sceneName_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) {extensionFieldSets_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) { + extensionFieldSets_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - - else { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - - - - - - - tlvReader.exitContainer() @@ -417,9 +360,11 @@ class AttributeListAttribute( ) } - suspend fun removeScene(groupID: UShort - ,sceneID: UByte - ,timedInvokeTimeout: Duration? = null): RemoveSceneResponse { + suspend fun removeScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeout: Duration? = null + ): RemoveSceneResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -429,7 +374,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -446,65 +391,59 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } - else { + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - tlvReader.exitContainer() - return RemoveSceneResponse( - status_decoded, - groupID_decoded, - sceneID_decoded - ) + return RemoveSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) } - suspend fun removeAllScenes(groupID: UShort - ,timedInvokeTimeout: Duration? = null): RemoveAllScenesResponse { + suspend fun removeAllScenes( + groupID: UShort, + timedInvokeTimeout: Duration? = null + ): RemoveAllScenesResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -521,48 +460,42 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - tlvReader.exitContainer() - return RemoveAllScenesResponse( - status_decoded, - groupID_decoded - ) + return RemoveAllScenesResponse(status_decoded, groupID_decoded) } - suspend fun storeScene(groupID: UShort - ,sceneID: UByte - ,timedInvokeTimeout: Duration? = null): StoreSceneResponse { + suspend fun storeScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeout: Duration? = null + ): StoreSceneResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -572,7 +505,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -589,60 +522,54 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - tlvReader.exitContainer() - return StoreSceneResponse( - status_decoded, - groupID_decoded, - sceneID_decoded - ) + return StoreSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) } - suspend fun recallScene(groupID: UShort - ,sceneID: UByte - ,transitionTime: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun recallScene( + groupID: UShort, + sceneID: UByte, + transitionTime: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -657,7 +584,7 @@ class AttributeListAttribute( val TAG_TRANSITION_TIME_REQ: Int = 2 transitionTime?.let { tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -671,15 +598,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getSceneMembership(groupID: UShort - ,timedInvokeTimeout: Duration? = null): GetSceneMembershipResponse { + suspend fun getSceneMembership( + groupID: UShort, + timedInvokeTimeout: Duration? = null + ): GetSceneMembershipResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -696,77 +625,72 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_CAPACITY: Int = 1 var capacity_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 2 var groupID_decoded: UShort? = null - + val TAG_SCENE_LIST: Int = 3 var sceneList_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_CAPACITY)) {capacity_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_CAPACITY)) { + capacity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_LIST)) {sceneList_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_LIST)) { + sceneList_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - - else { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - - tlvReader.exitContainer() @@ -778,12 +702,14 @@ class AttributeListAttribute( ) } - suspend fun copyScene(mode: UByte - ,groupIdentifierFrom: UShort - ,sceneIdentifierFrom: UByte - ,groupIdentifierTo: UShort - ,sceneIdentifierTo: UByte - ,timedInvokeTimeout: Duration? = null): CopySceneResponse { + suspend fun copyScene( + mode: UByte, + groupIdentifierFrom: UShort, + sceneIdentifierFrom: UByte, + groupIdentifierTo: UShort, + sceneIdentifierTo: UByte, + timedInvokeTimeout: Duration? = null + ): CopySceneResponse { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -802,7 +728,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_IDENTIFIER_TO_REQ), groupIdentifierTo) val TAG_SCENE_IDENTIFIER_TO_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_IDENTIFIER_TO_REQ), sceneIdentifierTo) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_IDENTIFIER_TO_REQ), sceneIdentifierTo) tlvWriter.endStructure() val request: InvokeRequest = @@ -819,46 +745,42 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_IDENTIFIER_FROM: Int = 1 var groupIdentifierFrom_decoded: UShort? = null - + val TAG_SCENE_IDENTIFIER_FROM: Int = 2 var sceneIdentifierFrom_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_IDENTIFIER_FROM)) {groupIdentifierFrom_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_IDENTIFIER_FROM)) {sceneIdentifierFrom_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_IDENTIFIER_FROM)) { + groupIdentifierFrom_decoded = tlvReader.getUShort(tag) + } - else { + if (tag == ContextSpecificTag(TAG_SCENE_IDENTIFIER_FROM)) { + sceneIdentifierFrom_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupIdentifierFrom_decoded == null) { - throw IllegalStateException("groupIdentifierFrom not found in TLV") + throw IllegalStateException("groupIdentifierFrom not found in TLV") } - - + if (sceneIdentifierFrom_decoded == null) { - throw IllegalStateException("sceneIdentifierFrom not found in TLV") + throw IllegalStateException("sceneIdentifierFrom not found in TLV") } - tlvReader.exitContainer() @@ -868,50 +790,44 @@ class AttributeListAttribute( sceneIdentifierFrom_decoded ) } -suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastconfiguredby attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastconfiguredby attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastConfiguredByAttribute(decodedValue) } @@ -921,96 +837,91 @@ suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastConfiguredByAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastConfiguredByAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastconfiguredby attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastconfiguredby attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LastConfiguredByAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LastConfiguredByAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastConfiguredByAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSceneTableSizeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSceneTableSizeAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scenetablesize attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scenetablesize attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1019,34 +930,38 @@ suspend fun readSceneTableSizeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scenetablesize attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scenetablesize attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1059,49 +974,43 @@ suspend fun readSceneTableSizeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fabricsceneinfo attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fabricsceneinfo attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return FabricSceneInfoAttribute(decodedValue) } @@ -1111,45 +1020,50 @@ suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FabricSceneInfoAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FabricSceneInfoAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fabricsceneinfo attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Fabricsceneinfo attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(FabricSceneInfoAttributeSubscriptionState.Success(decodedValue)) } @@ -1157,49 +1071,43 @@ suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute {val ATTRIB emit(FabricSceneInfoAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1209,45 +1117,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1255,49 +1168,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1307,45 +1214,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1353,49 +1265,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1405,45 +1311,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1451,49 +1360,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1503,45 +1406,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1549,44 +1455,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1595,35 +1494,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1635,44 +1536,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1681,34 +1575,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1721,7 +1619,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ServiceAreaCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ServiceAreaCluster.kt index fa3784d960ce3c..11203b5f2a99b7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ServiceAreaCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ServiceAreaCluster.kt @@ -17,191 +17,140 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class ServiceAreaCluster(private val controller: MatterController, private val endpointId: UShort) { - class SelectLocationsResponse( - val status: UByte, - val statusText: String? - ) - - class SkipCurrentLocationResponse( - val status: UByte, - val statusText: String? - ) -class SupportedLocationsAttribute( - val value: List - ) + class SelectLocationsResponse(val status: UByte, val statusText: String?) + + class SkipCurrentLocationResponse(val status: UByte, val statusText: String?) + + class SupportedLocationsAttribute(val value: List) sealed class SupportedLocationsAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedLocationsAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedLocationsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedLocationsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedLocationsAttributeSubscriptionState() - } -class SupportedMapsAttribute( - val value: List? - ) + object SubscriptionEstablished : SupportedLocationsAttributeSubscriptionState() + } + + class SupportedMapsAttribute(val value: List?) sealed class SupportedMapsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedMapsAttributeSubscriptionState() - + data class Success(val value: List?) : + SupportedMapsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedMapsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedMapsAttributeSubscriptionState() - } -class SelectedLocationsAttribute( - val value: List? - ) + object SubscriptionEstablished : SupportedMapsAttributeSubscriptionState() + } + + class SelectedLocationsAttribute(val value: List?) sealed class SelectedLocationsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SelectedLocationsAttributeSubscriptionState() - + data class Success(val value: List?) : SelectedLocationsAttributeSubscriptionState() + data class Error(val exception: Exception) : SelectedLocationsAttributeSubscriptionState() - object SubscriptionEstablished : SelectedLocationsAttributeSubscriptionState() - } -class CurrentLocationAttribute( - val value: UInt? - ) + object SubscriptionEstablished : SelectedLocationsAttributeSubscriptionState() + } + + class CurrentLocationAttribute(val value: UInt?) sealed class CurrentLocationAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : CurrentLocationAttributeSubscriptionState() - + data class Success(val value: UInt?) : CurrentLocationAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentLocationAttributeSubscriptionState() - object SubscriptionEstablished : CurrentLocationAttributeSubscriptionState() - } -class EstimatedEndTimeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : CurrentLocationAttributeSubscriptionState() + } + + class EstimatedEndTimeAttribute(val value: UInt?) sealed class EstimatedEndTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : EstimatedEndTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : EstimatedEndTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : EstimatedEndTimeAttributeSubscriptionState() - object SubscriptionEstablished : EstimatedEndTimeAttributeSubscriptionState() - } -class ProgressAttribute( - val value: List? - ) + object SubscriptionEstablished : EstimatedEndTimeAttributeSubscriptionState() + } + + class ProgressAttribute(val value: List?) sealed class ProgressAttributeSubscriptionState { - data class Success( - val value: List? - ) : ProgressAttributeSubscriptionState() - + data class Success(val value: List?) : + ProgressAttributeSubscriptionState() + data class Error(val exception: Exception) : ProgressAttributeSubscriptionState() - object SubscriptionEstablished : ProgressAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ProgressAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun selectLocations(newLocations: List? - ,timedInvokeTimeout: Duration? = null): SelectLocationsResponse { + suspend fun selectLocations( + newLocations: List?, + timedInvokeTimeout: Duration? = null + ): SelectLocationsResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -214,7 +163,7 @@ class AttributeListAttribute( tlvWriter.put(AnonymousTag, item) } tlvWriter.endArray() - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -231,57 +180,50 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return SelectLocationsResponse( - status_decoded, - statusText_decoded - ) + return SelectLocationsResponse(status_decoded, statusText_decoded) } - suspend fun skipCurrentLocation(timedInvokeTimeout: Duration? = null): SkipCurrentLocationResponse { + suspend fun skipCurrentLocation( + timedInvokeTimeout: Duration? = null + ): SkipCurrentLocationResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -298,92 +240,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return SkipCurrentLocationResponse( - status_decoded, - statusText_decoded - ) + return SkipCurrentLocationResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedLocationsAttribute(): SupportedLocationsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedLocationsAttribute(): SupportedLocationsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedlocations attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedlocations attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ServiceAreaClusterLocationStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ServiceAreaClusterLocationStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedLocationsAttribute(decodedValue) } @@ -393,45 +320,50 @@ suspend fun readSupportedLocationsAttribute(): SupportedLocationsAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedLocationsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedLocationsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedlocations attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedlocations attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ServiceAreaClusterLocationStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ServiceAreaClusterLocationStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedLocationsAttributeSubscriptionState.Success(decodedValue)) } @@ -439,54 +371,48 @@ suspend fun readSupportedLocationsAttribute(): SupportedLocationsAttribute {val emit(SupportedLocationsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedMapsAttribute(): SupportedMapsAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedMapsAttribute(): SupportedMapsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmaps attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmaps attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ServiceAreaClusterMapStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ServiceAreaClusterMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return SupportedMapsAttribute(decodedValue) } @@ -496,108 +422,102 @@ suspend fun readSupportedMapsAttribute(): SupportedMapsAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedMapsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedMapsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmaps attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Supportedmaps attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ServiceAreaClusterMapStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SupportedMapsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ServiceAreaClusterMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SupportedMapsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SupportedMapsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSelectedLocationsAttribute(): SelectedLocationsAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSelectedLocationsAttribute(): SelectedLocationsAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedlocations attribute not found in response" - } + } + + requireNotNull(attributeData) { "Selectedlocations attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return SelectedLocationsAttribute(decodedValue) } @@ -607,106 +527,102 @@ suspend fun readSelectedLocationsAttribute(): SelectedLocationsAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SelectedLocationsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SelectedLocationsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedlocations attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Selectedlocations attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SelectedLocationsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SelectedLocationsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SelectedLocationsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentLocationAttribute(): CurrentLocationAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentLocationAttribute(): CurrentLocationAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlocation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentlocation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentLocationAttribute(decodedValue) } @@ -716,104 +632,100 @@ suspend fun readCurrentLocationAttribute(): CurrentLocationAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentLocationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentLocationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlocation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentlocation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentLocationAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentLocationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentLocationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEstimatedEndTimeAttribute(): EstimatedEndTimeAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEstimatedEndTimeAttribute(): EstimatedEndTimeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Estimatedendtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Estimatedendtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return EstimatedEndTimeAttribute(decodedValue) } @@ -823,110 +735,106 @@ suspend fun readEstimatedEndTimeAttribute(): EstimatedEndTimeAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EstimatedEndTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EstimatedEndTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Estimatedendtime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Estimatedendtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(EstimatedEndTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(EstimatedEndTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(EstimatedEndTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProgressAttribute(): ProgressAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProgressAttribute(): ProgressAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Progress attribute not found in response" - } + } + + requireNotNull(attributeData) { "Progress attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ServiceAreaClusterProgressStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ServiceAreaClusterProgressStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return ProgressAttribute(decodedValue) } @@ -936,107 +844,101 @@ suspend fun readProgressAttribute(): ProgressAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ProgressAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ProgressAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Progress attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Progress attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ServiceAreaClusterProgressStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ProgressAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ServiceAreaClusterProgressStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ProgressAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ProgressAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1046,45 +948,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1092,49 +999,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1144,45 +1045,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1190,49 +1096,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1242,45 +1142,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1288,49 +1191,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1340,45 +1237,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1386,44 +1286,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1432,35 +1325,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1472,44 +1367,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1518,34 +1406,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1558,7 +1450,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt index ec9ca8d0e7e65a..12a337827e4c2c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt @@ -17,106 +17,81 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class SmokeCoAlarmCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun selfTestRequest(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -129,42 +104,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readExpressedStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readExpressedStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expressedstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Expressedstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -173,34 +141,38 @@ suspend fun readExpressedStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expressedstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Expressedstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -213,47 +185,41 @@ suspend fun readExpressedStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSmokeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSmokeStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Smokestate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Smokestate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -263,94 +229,88 @@ suspend fun readSmokeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Smokestate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Smokestate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCOStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCOStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Costate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Costate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -360,91 +320,84 @@ suspend fun readCOStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Costate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Costate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatteryAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBatteryAlertAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batteryalert attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batteryalert attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -453,35 +406,37 @@ suspend fun readBatteryAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batteryalert attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batteryalert attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -493,47 +448,41 @@ suspend fun readBatteryAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDeviceMutedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDeviceMutedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Devicemuted attribute not found in response" - } + } + + requireNotNull(attributeData) { "Devicemuted attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -543,91 +492,84 @@ suspend fun readDeviceMutedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Devicemuted attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Devicemuted attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTestInProgressAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTestInProgressAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Testinprogress attribute not found in response" - } + } + + requireNotNull(attributeData) { "Testinprogress attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -636,34 +578,38 @@ suspend fun readTestInProgressAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Testinprogress attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Testinprogress attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -676,44 +622,37 @@ suspend fun readTestInProgressAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 5u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareFaultAlertAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readHardwareFaultAlertAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwarefaultalert attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwarefaultalert attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -722,34 +661,38 @@ suspend fun readHardwareFaultAlertAttribute(): Boolean {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwarefaultalert attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwarefaultalert attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -762,44 +705,37 @@ suspend fun readHardwareFaultAlertAttribute(): Boolean {val ATTRIBUTE_ID: UInt = emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEndOfServiceAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEndOfServiceAlertAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endofservicealert attribute not found in response" - } + } + + requireNotNull(attributeData) { "Endofservicealert attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -808,34 +744,38 @@ suspend fun readEndOfServiceAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endofservicealert attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Endofservicealert attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -848,47 +788,41 @@ suspend fun readEndOfServiceAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInterconnectSmokeAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInterconnectSmokeAlarmAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interconnectsmokealarm attribute not found in response" - } + } + + requireNotNull(attributeData) { "Interconnectsmokealarm attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -898,94 +832,90 @@ suspend fun readInterconnectSmokeAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interconnectsmokealarm attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Interconnectsmokealarm attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInterconnectCOAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInterconnectCOAlarmAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interconnectcoalarm attribute not found in response" - } + } + + requireNotNull(attributeData) { "Interconnectcoalarm attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -995,94 +925,90 @@ suspend fun readInterconnectCOAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interconnectcoalarm attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Interconnectcoalarm attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readContaminationStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readContaminationStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Contaminationstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Contaminationstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1092,118 +1018,113 @@ suspend fun readContaminationStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Contaminationstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Contaminationstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSmokeSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSmokeSensitivityLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Smokesensitivitylevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Smokesensitivitylevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeSmokeSensitivityLevelAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 11u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1225,7 +1146,7 @@ suspend fun readSmokeSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSmokeSensitivityLevelAttribute( @@ -1233,94 +1154,90 @@ suspend fun readSmokeSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Smokesensitivitylevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Smokesensitivitylevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readExpiryDateAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 12u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readExpiryDateAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expirydate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Expirydate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -1330,96 +1247,90 @@ suspend fun readExpiryDateAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 12u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expirydate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Expirydate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1429,45 +1340,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1475,49 +1391,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1527,45 +1437,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1573,49 +1488,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1625,45 +1534,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1671,49 +1583,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1723,45 +1629,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1769,44 +1678,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1815,35 +1717,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1855,44 +1759,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1901,34 +1798,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1941,7 +1842,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt index 3e60be49a852ca..c3568e5825e8fe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt @@ -17,119 +17,88 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SoftwareDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class ThreadMetricsAttribute( - val value: List? - ) +class SoftwareDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ThreadMetricsAttribute(val value: List?) sealed class ThreadMetricsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ThreadMetricsAttributeSubscriptionState() - + data class Success(val value: List?) : + ThreadMetricsAttributeSubscriptionState() + data class Error(val exception: Exception) : ThreadMetricsAttributeSubscriptionState() - object SubscriptionEstablished : ThreadMetricsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ThreadMetricsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetWatermarks(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -142,51 +111,45 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadmetrics attribute not found in response" - } + } + + requireNotNull(attributeData) { "Threadmetrics attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ThreadMetricsAttribute(decodedValue) } @@ -196,100 +159,96 @@ suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ThreadMetricsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ThreadMetricsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadmetrics attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Threadmetrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ThreadMetricsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ThreadMetricsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ThreadMetricsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentHeapFreeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentHeapFreeAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheapfree attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentheapfree attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -299,94 +258,90 @@ suspend fun readCurrentHeapFreeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheapfree attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentheapfree attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentHeapUsedAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentHeapUsedAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheapused attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentheapused attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -396,94 +351,90 @@ suspend fun readCurrentHeapUsedAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheapused attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentheapused attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentHeapHighWatermarkAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentHeapHighWatermarkAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheaphighwatermark attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentheaphighwatermark attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -493,96 +444,92 @@ suspend fun readCurrentHeapHighWatermarkAttribute(): ULong? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheaphighwatermark attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentheaphighwatermark attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -592,45 +539,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -638,49 +590,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -690,45 +636,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -736,49 +687,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -788,45 +733,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -834,49 +782,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -886,45 +828,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -932,44 +877,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -978,35 +916,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1018,44 +958,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1064,34 +997,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1104,7 +1041,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt index 0462ac9b0c886c..ec30f6aa7452e6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt @@ -17,136 +17,93 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class SwitchCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class SwitchCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readNumberOfPositionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readNumberOfPositionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpositions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofpositions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -155,34 +112,38 @@ suspend fun readNumberOfPositionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpositions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofpositions attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -195,44 +156,37 @@ suspend fun readNumberOfPositionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentPositionAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentposition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentposition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -241,34 +195,38 @@ suspend fun readCurrentPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentposition attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -281,47 +239,41 @@ suspend fun readCurrentPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMultiPressMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMultiPressMaxAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Multipressmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Multipressmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -331,96 +283,90 @@ suspend fun readMultiPressMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Multipressmax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Multipressmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -430,45 +376,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -476,49 +427,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -528,45 +473,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -574,49 +524,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -626,45 +570,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -672,49 +619,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -724,45 +665,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -770,44 +714,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -816,35 +753,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -856,44 +795,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -902,34 +834,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -942,7 +878,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt index c7aee150c59e6c..aa48d2e32d4736 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt @@ -17,122 +17,91 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TargetNavigatorCluster(private val controller: MatterController, private val endpointId: UShort) { - class NavigateTargetResponse( - val status: UByte, - val data: String? - ) -class TargetListAttribute( - val value: List - ) +class TargetNavigatorCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class NavigateTargetResponse(val status: UByte, val data: String?) + + class TargetListAttribute(val value: List) sealed class TargetListAttributeSubscriptionState { - data class Success( - val value: List - ) : TargetListAttributeSubscriptionState() - + data class Success(val value: List) : + TargetListAttributeSubscriptionState() + data class Error(val exception: Exception) : TargetListAttributeSubscriptionState() - object SubscriptionEstablished : TargetListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : TargetListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun navigateTarget(target: UByte - ,data: String? - ,timedInvokeTimeout: Duration? = null): NavigateTargetResponse { + suspend fun navigateTarget( + target: UByte, + data: String?, + timedInvokeTimeout: Duration? = null + ): NavigateTargetResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -142,9 +111,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_TARGET_REQ), target) val TAG_DATA_REQ: Int = 1 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } tlvWriter.endStructure() val request: InvokeRequest = @@ -161,92 +128,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return NavigateTargetResponse( - status_decoded, - data_decoded - ) + return NavigateTargetResponse(status_decoded, data_decoded) } -suspend fun readTargetListAttribute(): TargetListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTargetListAttribute(): TargetListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Targetlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return TargetListAttribute(decodedValue) } @@ -256,45 +208,48 @@ suspend fun readTargetListAttribute(): TargetListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Targetlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(TargetListAttributeSubscriptionState.Success(decodedValue)) } @@ -302,47 +257,41 @@ suspend fun readTargetListAttribute(): TargetListAttribute {val ATTRIBUTE_ID: UI emit(TargetListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentTargetAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentTargetAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenttarget attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currenttarget attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -352,96 +301,90 @@ suspend fun readCurrentTargetAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenttarget attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currenttarget attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -451,45 +394,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -497,49 +445,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -549,45 +491,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -595,49 +542,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -647,45 +588,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -693,49 +637,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -745,45 +683,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -791,44 +732,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -837,35 +771,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -877,44 +813,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -923,34 +852,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -963,7 +896,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt index 879479e9577967..ef8fa756028407 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt @@ -17,117 +17,91 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.ShortSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TemperatureControlCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedTemperatureLevelsAttribute( - val value: List? - ) +class TemperatureControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedTemperatureLevelsAttribute(val value: List?) sealed class SupportedTemperatureLevelsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedTemperatureLevelsAttributeSubscriptionState() - - data class Error(val exception: Exception) : SupportedTemperatureLevelsAttributeSubscriptionState() - - object SubscriptionEstablished : SupportedTemperatureLevelsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List?) : + SupportedTemperatureLevelsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + SupportedTemperatureLevelsAttributeSubscriptionState() + + object SubscriptionEstablished : SupportedTemperatureLevelsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setTemperature(targetTemperature: Short? - ,targetTemperatureLevel: UByte? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setTemperature( + targetTemperature: Short?, + targetTemperatureLevel: UByte?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -141,7 +115,7 @@ class AttributeListAttribute( val TAG_TARGET_TEMPERATURE_LEVEL_REQ: Int = 1 targetTemperatureLevel?.let { tlvWriter.put(ContextSpecificTag(TAG_TARGET_TEMPERATURE_LEVEL_REQ), targetTemperatureLevel) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -154,45 +128,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readTemperatureSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTemperatureSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Temperaturesetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -202,94 +170,90 @@ suspend fun readTemperatureSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturesetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinTemperatureAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mintemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mintemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -299,94 +263,90 @@ suspend fun readMinTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mintemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Mintemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxTemperatureAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxtemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxtemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -396,94 +356,90 @@ suspend fun readMaxTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxtemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxtemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStepAttribute(): Short? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStepAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Step attribute not found in response" - } + } + + requireNotNull(attributeData) { "Step attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -493,94 +449,88 @@ suspend fun readStepAttribute(): Short? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Step attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Step attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSelectedTemperatureLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSelectedTemperatureLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedtemperaturelevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Selectedtemperaturelevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -590,100 +540,96 @@ suspend fun readSelectedTemperatureLevelAttribute(): UByte? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedtemperaturelevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Selectedtemperaturelevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevelsAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevelsAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedtemperaturelevels attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedtemperaturelevels attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedTemperatureLevelsAttribute(decodedValue) } @@ -693,102 +639,100 @@ suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevel maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedTemperatureLevelsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedTemperatureLevelsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedtemperaturelevels attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedtemperaturelevels attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { emit(SupportedTemperatureLevelsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(SupportedTemperatureLevelsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -798,45 +742,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -844,49 +793,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -896,45 +839,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -942,49 +890,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -994,45 +936,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1040,49 +985,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1092,45 +1031,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1138,44 +1080,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1184,35 +1119,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1224,44 +1161,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1270,34 +1200,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1310,7 +1244,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt index ef6d1043bbbf5b..5cd6ac3392242f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt @@ -17,179 +17,130 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class TemperatureMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Short? - ) +class TemperatureMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Short?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Short?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Short?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -199,96 +150,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -298,96 +243,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -397,95 +338,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -495,96 +432,90 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -594,45 +525,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -640,49 +576,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -692,45 +622,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -738,49 +673,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -790,45 +719,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -836,49 +768,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -888,45 +814,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -934,44 +863,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -980,35 +902,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1020,44 +944,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1066,34 +983,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1106,7 +1027,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt index f64bc24d5bee34..2fa28950db06cd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt @@ -17,371 +17,294 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.ShortSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class ThermostatCluster(private val controller: MatterController, private val endpointId: UShort) { class GetWeeklyScheduleResponse( - val numberOfTransitionsForSequence: UByte, - val dayOfWeekForSequence: UByte, - val modeForSequence: UByte, + val numberOfTransitionsForSequence: UByte, + val dayOfWeekForSequence: UByte, + val modeForSequence: UByte, val transitions: List ) -class LocalTemperatureAttribute( - val value: Short? - ) + + class LocalTemperatureAttribute(val value: Short?) sealed class LocalTemperatureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : LocalTemperatureAttributeSubscriptionState() - + data class Success(val value: Short?) : LocalTemperatureAttributeSubscriptionState() + data class Error(val exception: Exception) : LocalTemperatureAttributeSubscriptionState() - object SubscriptionEstablished : LocalTemperatureAttributeSubscriptionState() - } -class OutdoorTemperatureAttribute( - val value: Short? - ) + object SubscriptionEstablished : LocalTemperatureAttributeSubscriptionState() + } + + class OutdoorTemperatureAttribute(val value: Short?) sealed class OutdoorTemperatureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : OutdoorTemperatureAttributeSubscriptionState() - + data class Success(val value: Short?) : OutdoorTemperatureAttributeSubscriptionState() + data class Error(val exception: Exception) : OutdoorTemperatureAttributeSubscriptionState() - object SubscriptionEstablished : OutdoorTemperatureAttributeSubscriptionState() - } -class TemperatureSetpointHoldDurationAttribute( - val value: UShort? - ) + object SubscriptionEstablished : OutdoorTemperatureAttributeSubscriptionState() + } + + class TemperatureSetpointHoldDurationAttribute(val value: UShort?) sealed class TemperatureSetpointHoldDurationAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : TemperatureSetpointHoldDurationAttributeSubscriptionState() - - data class Error(val exception: Exception) : TemperatureSetpointHoldDurationAttributeSubscriptionState() - - object SubscriptionEstablished : TemperatureSetpointHoldDurationAttributeSubscriptionState() - } -class SetpointChangeAmountAttribute( - val value: Short? - ) + data class Success(val value: UShort?) : + TemperatureSetpointHoldDurationAttributeSubscriptionState() + + data class Error(val exception: Exception) : + TemperatureSetpointHoldDurationAttributeSubscriptionState() + + object SubscriptionEstablished : TemperatureSetpointHoldDurationAttributeSubscriptionState() + } + + class SetpointChangeAmountAttribute(val value: Short?) sealed class SetpointChangeAmountAttributeSubscriptionState { - data class Success( - val value: Short? - ) : SetpointChangeAmountAttributeSubscriptionState() - + data class Success(val value: Short?) : SetpointChangeAmountAttributeSubscriptionState() + data class Error(val exception: Exception) : SetpointChangeAmountAttributeSubscriptionState() - object SubscriptionEstablished : SetpointChangeAmountAttributeSubscriptionState() - } -class OccupiedSetbackAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SetpointChangeAmountAttributeSubscriptionState() + } + + class OccupiedSetbackAttribute(val value: UByte?) sealed class OccupiedSetbackAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OccupiedSetbackAttributeSubscriptionState() - + data class Success(val value: UByte?) : OccupiedSetbackAttributeSubscriptionState() + data class Error(val exception: Exception) : OccupiedSetbackAttributeSubscriptionState() - object SubscriptionEstablished : OccupiedSetbackAttributeSubscriptionState() - } -class OccupiedSetbackMinAttribute( - val value: UByte? - ) + object SubscriptionEstablished : OccupiedSetbackAttributeSubscriptionState() + } + + class OccupiedSetbackMinAttribute(val value: UByte?) sealed class OccupiedSetbackMinAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OccupiedSetbackMinAttributeSubscriptionState() - + data class Success(val value: UByte?) : OccupiedSetbackMinAttributeSubscriptionState() + data class Error(val exception: Exception) : OccupiedSetbackMinAttributeSubscriptionState() - object SubscriptionEstablished : OccupiedSetbackMinAttributeSubscriptionState() - } -class OccupiedSetbackMaxAttribute( - val value: UByte? - ) + object SubscriptionEstablished : OccupiedSetbackMinAttributeSubscriptionState() + } + + class OccupiedSetbackMaxAttribute(val value: UByte?) sealed class OccupiedSetbackMaxAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OccupiedSetbackMaxAttributeSubscriptionState() - + data class Success(val value: UByte?) : OccupiedSetbackMaxAttributeSubscriptionState() + data class Error(val exception: Exception) : OccupiedSetbackMaxAttributeSubscriptionState() - object SubscriptionEstablished : OccupiedSetbackMaxAttributeSubscriptionState() - } -class UnoccupiedSetbackAttribute( - val value: UByte? - ) + object SubscriptionEstablished : OccupiedSetbackMaxAttributeSubscriptionState() + } + + class UnoccupiedSetbackAttribute(val value: UByte?) sealed class UnoccupiedSetbackAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : UnoccupiedSetbackAttributeSubscriptionState() - + data class Success(val value: UByte?) : UnoccupiedSetbackAttributeSubscriptionState() + data class Error(val exception: Exception) : UnoccupiedSetbackAttributeSubscriptionState() - object SubscriptionEstablished : UnoccupiedSetbackAttributeSubscriptionState() - } -class UnoccupiedSetbackMinAttribute( - val value: UByte? - ) + object SubscriptionEstablished : UnoccupiedSetbackAttributeSubscriptionState() + } + + class UnoccupiedSetbackMinAttribute(val value: UByte?) sealed class UnoccupiedSetbackMinAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : UnoccupiedSetbackMinAttributeSubscriptionState() - + data class Success(val value: UByte?) : UnoccupiedSetbackMinAttributeSubscriptionState() + data class Error(val exception: Exception) : UnoccupiedSetbackMinAttributeSubscriptionState() - object SubscriptionEstablished : UnoccupiedSetbackMinAttributeSubscriptionState() - } -class UnoccupiedSetbackMaxAttribute( - val value: UByte? - ) + object SubscriptionEstablished : UnoccupiedSetbackMinAttributeSubscriptionState() + } + + class UnoccupiedSetbackMaxAttribute(val value: UByte?) sealed class UnoccupiedSetbackMaxAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : UnoccupiedSetbackMaxAttributeSubscriptionState() - + data class Success(val value: UByte?) : UnoccupiedSetbackMaxAttributeSubscriptionState() + data class Error(val exception: Exception) : UnoccupiedSetbackMaxAttributeSubscriptionState() - object SubscriptionEstablished : UnoccupiedSetbackMaxAttributeSubscriptionState() - } -class ACCoilTemperatureAttribute( - val value: Short? - ) + object SubscriptionEstablished : UnoccupiedSetbackMaxAttributeSubscriptionState() + } + + class ACCoilTemperatureAttribute(val value: Short?) sealed class ACCoilTemperatureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : ACCoilTemperatureAttributeSubscriptionState() - + data class Success(val value: Short?) : ACCoilTemperatureAttributeSubscriptionState() + data class Error(val exception: Exception) : ACCoilTemperatureAttributeSubscriptionState() - object SubscriptionEstablished : ACCoilTemperatureAttributeSubscriptionState() - } -class PresetTypesAttribute( - val value: List? - ) + object SubscriptionEstablished : ACCoilTemperatureAttributeSubscriptionState() + } + + class PresetTypesAttribute(val value: List?) sealed class PresetTypesAttributeSubscriptionState { - data class Success( - val value: List? - ) : PresetTypesAttributeSubscriptionState() - + data class Success(val value: List?) : + PresetTypesAttributeSubscriptionState() + data class Error(val exception: Exception) : PresetTypesAttributeSubscriptionState() - object SubscriptionEstablished : PresetTypesAttributeSubscriptionState() - } -class ScheduleTypesAttribute( - val value: List? - ) + object SubscriptionEstablished : PresetTypesAttributeSubscriptionState() + } + + class ScheduleTypesAttribute(val value: List?) sealed class ScheduleTypesAttributeSubscriptionState { - data class Success( - val value: List? - ) : ScheduleTypesAttributeSubscriptionState() - + data class Success(val value: List?) : + ScheduleTypesAttributeSubscriptionState() + data class Error(val exception: Exception) : ScheduleTypesAttributeSubscriptionState() - object SubscriptionEstablished : ScheduleTypesAttributeSubscriptionState() - } -class NumberOfScheduleTransitionPerDayAttribute( - val value: UByte? - ) + object SubscriptionEstablished : ScheduleTypesAttributeSubscriptionState() + } + + class NumberOfScheduleTransitionPerDayAttribute(val value: UByte?) sealed class NumberOfScheduleTransitionPerDayAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() - - data class Error(val exception: Exception) : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() - - object SubscriptionEstablished : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() - } -class ActivePresetHandleAttribute( - val value: ByteArray? - ) + data class Success(val value: UByte?) : + NumberOfScheduleTransitionPerDayAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NumberOfScheduleTransitionPerDayAttributeSubscriptionState() + + object SubscriptionEstablished : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() + } + + class ActivePresetHandleAttribute(val value: ByteArray?) sealed class ActivePresetHandleAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : ActivePresetHandleAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : ActivePresetHandleAttributeSubscriptionState() + data class Error(val exception: Exception) : ActivePresetHandleAttributeSubscriptionState() - object SubscriptionEstablished : ActivePresetHandleAttributeSubscriptionState() - } -class ActiveScheduleHandleAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : ActivePresetHandleAttributeSubscriptionState() + } + + class ActiveScheduleHandleAttribute(val value: ByteArray?) sealed class ActiveScheduleHandleAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : ActiveScheduleHandleAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : ActiveScheduleHandleAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveScheduleHandleAttributeSubscriptionState() - object SubscriptionEstablished : ActiveScheduleHandleAttributeSubscriptionState() - } -class PresetsAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveScheduleHandleAttributeSubscriptionState() + } + + class PresetsAttribute(val value: List?) sealed class PresetsAttributeSubscriptionState { - data class Success( - val value: List? - ) : PresetsAttributeSubscriptionState() - + data class Success(val value: List?) : + PresetsAttributeSubscriptionState() + data class Error(val exception: Exception) : PresetsAttributeSubscriptionState() - object SubscriptionEstablished : PresetsAttributeSubscriptionState() - } -class SchedulesAttribute( - val value: List? - ) + object SubscriptionEstablished : PresetsAttributeSubscriptionState() + } + + class SchedulesAttribute(val value: List?) sealed class SchedulesAttributeSubscriptionState { - data class Success( - val value: List? - ) : SchedulesAttributeSubscriptionState() - + data class Success(val value: List?) : + SchedulesAttributeSubscriptionState() + data class Error(val exception: Exception) : SchedulesAttributeSubscriptionState() - object SubscriptionEstablished : SchedulesAttributeSubscriptionState() - } -class SetpointHoldExpiryTimestampAttribute( - val value: UInt? - ) + object SubscriptionEstablished : SchedulesAttributeSubscriptionState() + } + + class SetpointHoldExpiryTimestampAttribute(val value: UInt?) sealed class SetpointHoldExpiryTimestampAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : SetpointHoldExpiryTimestampAttributeSubscriptionState() - - data class Error(val exception: Exception) : SetpointHoldExpiryTimestampAttributeSubscriptionState() - - object SubscriptionEstablished : SetpointHoldExpiryTimestampAttributeSubscriptionState() - } -class QueuedPresetAttribute( - val value: ThermostatClusterQueuedPresetStruct? - ) + data class Success(val value: UInt?) : SetpointHoldExpiryTimestampAttributeSubscriptionState() + + data class Error(val exception: Exception) : + SetpointHoldExpiryTimestampAttributeSubscriptionState() + + object SubscriptionEstablished : SetpointHoldExpiryTimestampAttributeSubscriptionState() + } + + class QueuedPresetAttribute(val value: ThermostatClusterQueuedPresetStruct?) sealed class QueuedPresetAttributeSubscriptionState { - data class Success( - val value: ThermostatClusterQueuedPresetStruct? - ) : QueuedPresetAttributeSubscriptionState() - + data class Success(val value: ThermostatClusterQueuedPresetStruct?) : + QueuedPresetAttributeSubscriptionState() + data class Error(val exception: Exception) : QueuedPresetAttributeSubscriptionState() - object SubscriptionEstablished : QueuedPresetAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : QueuedPresetAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setpointRaiseLower(mode: UByte - ,amount: Byte - ,timedInvokeTimeout: Duration? = null) { + suspend fun setpointRaiseLower(mode: UByte, amount: Byte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -391,7 +314,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MODE_REQ), mode) val TAG_AMOUNT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_AMOUNT_REQ), amount) + tlvWriter.put(ContextSpecificTag(TAG_AMOUNT_REQ), amount) tlvWriter.endStructure() val request: InvokeRequest = @@ -405,18 +328,23 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setWeeklySchedule(numberOfTransitionsForSequence: UByte - ,dayOfWeekForSequence: UByte - ,modeForSequence: UByte - ,transitions: List - ,timedInvokeTimeout: Duration? = null) { + suspend fun setWeeklySchedule( + numberOfTransitionsForSequence: UByte, + dayOfWeekForSequence: UByte, + modeForSequence: UByte, + transitions: List, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ), numberOfTransitionsForSequence) + tlvWriter.put( + ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ), + numberOfTransitionsForSequence + ) val TAG_DAY_OF_WEEK_FOR_SEQUENCE_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE_REQ), dayOfWeekForSequence) @@ -426,10 +354,10 @@ class AttributeListAttribute( val TAG_TRANSITIONS_REQ: Int = 3 tlvWriter.startArray(ContextSpecificTag(TAG_TRANSITIONS_REQ)) - for (item in transitions.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in transitions.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -443,9 +371,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getWeeklySchedule(daysToReturn: UByte - ,modeToReturn: UByte - ,timedInvokeTimeout: Duration? = null): GetWeeklyScheduleResponse { + suspend fun getWeeklySchedule( + daysToReturn: UByte, + modeToReturn: UByte, + timedInvokeTimeout: Duration? = null + ): GetWeeklyScheduleResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -455,7 +385,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_DAYS_TO_RETURN_REQ), daysToReturn) val TAG_MODE_TO_RETURN_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_MODE_TO_RETURN_REQ), modeToReturn) + tlvWriter.put(ContextSpecificTag(TAG_MODE_TO_RETURN_REQ), modeToReturn) tlvWriter.endStructure() val request: InvokeRequest = @@ -472,62 +402,60 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE: Int = 0 var numberOfTransitionsForSequence_decoded: UByte? = null - + val TAG_DAY_OF_WEEK_FOR_SEQUENCE: Int = 1 var dayOfWeekForSequence_decoded: UByte? = null - + val TAG_MODE_FOR_SEQUENCE: Int = 2 var modeForSequence_decoded: UByte? = null - + val TAG_TRANSITIONS: Int = 3 var transitions_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE)) {numberOfTransitionsForSequence_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) {dayOfWeekForSequence_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_MODE_FOR_SEQUENCE)) {modeForSequence_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_TRANSITIONS)) {transitions_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterWeeklyScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }} - - - else { + if (tag == ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE)) { + numberOfTransitionsForSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) { + dayOfWeekForSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_MODE_FOR_SEQUENCE)) { + modeForSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_TRANSITIONS)) { + transitions_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterWeeklyScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (numberOfTransitionsForSequence_decoded == null) { - throw IllegalStateException("numberOfTransitionsForSequence not found in TLV") + throw IllegalStateException("numberOfTransitionsForSequence not found in TLV") } - - + if (dayOfWeekForSequence_decoded == null) { - throw IllegalStateException("dayOfWeekForSequence not found in TLV") + throw IllegalStateException("dayOfWeekForSequence not found in TLV") } - - + if (modeForSequence_decoded == null) { - throw IllegalStateException("modeForSequence not found in TLV") + throw IllegalStateException("modeForSequence not found in TLV") } - - + if (transitions_decoded == null) { - throw IllegalStateException("transitions not found in TLV") + throw IllegalStateException("transitions not found in TLV") } - tlvReader.exitContainer() @@ -543,7 +471,7 @@ class AttributeListAttribute( val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -557,15 +485,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setActiveScheduleRequest(scheduleHandle: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun setActiveScheduleRequest( + scheduleHandle: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SCHEDULE_HANDLE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SCHEDULE_HANDLE_REQ), scheduleHandle) + tlvWriter.put(ContextSpecificTag(TAG_SCHEDULE_HANDLE_REQ), scheduleHandle) tlvWriter.endStructure() val request: InvokeRequest = @@ -579,9 +509,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setActivePresetRequest(presetHandle: ByteArray - ,delayMinutes: UShort? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setActivePresetRequest( + presetHandle: ByteArray, + delayMinutes: UShort?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -591,9 +523,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_PRESET_HANDLE_REQ), presetHandle) val TAG_DELAY_MINUTES_REQ: Int = 1 - delayMinutes?.let { - tlvWriter.put(ContextSpecificTag(TAG_DELAY_MINUTES_REQ), delayMinutes) - } + delayMinutes?.let { tlvWriter.put(ContextSpecificTag(TAG_DELAY_MINUTES_REQ), delayMinutes) } tlvWriter.endStructure() val request: InvokeRequest = @@ -607,15 +537,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startPresetsSchedulesEditRequest(timeoutSeconds: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun startPresetsSchedulesEditRequest( + timeoutSeconds: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TIMEOUT_SECONDS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_SECONDS_REQ), timeoutSeconds) + tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_SECONDS_REQ), timeoutSeconds) tlvWriter.endStructure() val request: InvokeRequest = @@ -633,7 +565,7 @@ class AttributeListAttribute( val commandId: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -651,7 +583,7 @@ class AttributeListAttribute( val commandId: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -669,7 +601,7 @@ class AttributeListAttribute( val commandId: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -683,15 +615,20 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTemperatureSetpointHoldPolicy(temperatureSetpointHoldPolicy: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun setTemperatureSetpointHoldPolicy( + temperatureSetpointHoldPolicy: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TEMPERATURE_SETPOINT_HOLD_POLICY_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TEMPERATURE_SETPOINT_HOLD_POLICY_REQ), temperatureSetpointHoldPolicy) + tlvWriter.put( + ContextSpecificTag(TAG_TEMPERATURE_SETPOINT_HOLD_POLICY_REQ), + temperatureSetpointHoldPolicy + ) tlvWriter.endStructure() val request: InvokeRequest = @@ -704,46 +641,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localtemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LocalTemperatureAttribute(decodedValue) } @@ -753,100 +684,96 @@ suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LocalTemperatureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LocalTemperatureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Localtemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LocalTemperatureAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LocalTemperatureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LocalTemperatureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outdoortemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Outdoortemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OutdoorTemperatureAttribute(decodedValue) } @@ -856,99 +783,95 @@ suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OutdoorTemperatureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OutdoorTemperatureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outdoortemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Outdoortemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OutdoorTemperatureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OutdoorTemperatureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OutdoorTemperatureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupancyAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupancyAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupancy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -958,94 +881,88 @@ suspend fun readOccupancyAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Occupancy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAbsMinHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absminheatsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absminheatsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1055,94 +972,90 @@ suspend fun readAbsMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absminheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Absminheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxheatsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absmaxheatsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1152,94 +1065,90 @@ suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Absmaxheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAbsMinCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmincoolsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absmincoolsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1249,94 +1158,90 @@ suspend fun readAbsMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmincoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Absmincoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxcoolsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absmaxcoolsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1346,94 +1251,90 @@ suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxcoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Absmaxcoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPICoolingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPICoolingDemandAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Picoolingdemand attribute not found in response" - } + } + + requireNotNull(attributeData) { "Picoolingdemand attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1443,94 +1344,90 @@ suspend fun readPICoolingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Picoolingdemand attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Picoolingdemand attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPIHeatingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPIHeatingDemandAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Piheatingdemand attribute not found in response" - } + } + + requireNotNull(attributeData) { "Piheatingdemand attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1540,118 +1437,113 @@ suspend fun readPIHeatingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Piheatingdemand attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Piheatingdemand attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hvacsystemtypeconfiguration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hvacsystemtypeconfiguration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeHVACSystemTypeConfigurationAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1673,7 +1565,7 @@ suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? {val ATTRIBUTE_ID throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeHVACSystemTypeConfigurationAttribute( @@ -1681,118 +1573,113 @@ suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hvacsystemtypeconfiguration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hvacsystemtypeconfiguration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocalTemperatureCalibrationAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocalTemperatureCalibrationAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtemperaturecalibration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localtemperaturecalibration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeLocalTemperatureCalibrationAttribute( value: Byte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1814,7 +1701,7 @@ suspend fun readLocalTemperatureCalibrationAttribute(): Byte? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocalTemperatureCalibrationAttribute( @@ -1822,118 +1709,113 @@ suspend fun readLocalTemperatureCalibrationAttribute(): Byte? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtemperaturecalibration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Localtemperaturecalibration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedCoolingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedcoolingsetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedcoolingsetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeOccupiedCoolingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1955,7 +1837,7 @@ suspend fun readOccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOccupiedCoolingSetpointAttribute( @@ -1963,118 +1845,113 @@ suspend fun readOccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedcoolingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedcoolingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedHeatingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedheatingsetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedheatingsetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeOccupiedHeatingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2096,7 +1973,7 @@ suspend fun readOccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOccupiedHeatingSetpointAttribute( @@ -2104,118 +1981,113 @@ suspend fun readOccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedheatingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedheatingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedcoolingsetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedcoolingsetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUnoccupiedCoolingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 19u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2237,7 +2109,7 @@ suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnoccupiedCoolingSetpointAttribute( @@ -2245,118 +2117,113 @@ suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedcoolingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedcoolingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedheatingsetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedheatingsetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUnoccupiedHeatingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2378,7 +2245,7 @@ suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnoccupiedHeatingSetpointAttribute( @@ -2386,118 +2253,113 @@ suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedheatingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedheatingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minheatsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minheatsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeMinHeatSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2519,7 +2381,7 @@ suspend fun readMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinHeatSetpointLimitAttribute( @@ -2527,118 +2389,113 @@ suspend fun readMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxheatsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxheatsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeMaxHeatSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 22u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2660,7 +2517,7 @@ suspend fun readMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMaxHeatSetpointLimitAttribute( @@ -2668,118 +2525,113 @@ suspend fun readMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mincoolsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mincoolsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeMinCoolSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2801,7 +2653,7 @@ suspend fun readMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinCoolSetpointLimitAttribute( @@ -2809,118 +2661,113 @@ suspend fun readMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mincoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Mincoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcoolsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxcoolsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeMaxCoolSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 24u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2942,7 +2789,7 @@ suspend fun readMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMaxCoolSetpointLimitAttribute( @@ -2950,118 +2797,110 @@ suspend fun readMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxcoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinSetpointDeadBandAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinSetpointDeadBandAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minsetpointdeadband attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minsetpointdeadband attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeMinSetpointDeadBandAttribute( - value: Byte, - timedWriteTimeout: Duration? = null) { + suspend fun writeMinSetpointDeadBandAttribute(value: Byte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 25u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3083,7 +2922,7 @@ suspend fun readMinSetpointDeadBandAttribute(): Byte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinSetpointDeadBandAttribute( @@ -3091,118 +2930,110 @@ suspend fun readMinSetpointDeadBandAttribute(): Byte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minsetpointdeadband attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minsetpointdeadband attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemoteSensingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRemoteSensingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remotesensing attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remotesensing attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeRemoteSensingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeRemoteSensingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 26u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3224,7 +3055,7 @@ suspend fun readRemoteSensingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRemoteSensingAttribute( @@ -3232,114 +3063,106 @@ suspend fun readRemoteSensingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remotesensing attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Remotesensing attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readControlSequenceOfOperationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readControlSequenceOfOperationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Controlsequenceofoperation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Controlsequenceofoperation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } suspend fun writeControlSequenceOfOperationAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 27u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3361,7 +3184,7 @@ suspend fun readControlSequenceOfOperationAttribute(): UByte {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeControlSequenceOfOperationAttribute( @@ -3369,34 +3192,38 @@ suspend fun readControlSequenceOfOperationAttribute(): UByte {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Controlsequenceofoperation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Controlsequenceofoperation attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3409,67 +3236,56 @@ suspend fun readControlSequenceOfOperationAttribute(): UByte {val ATTRIBUTE_ID: emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSystemModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSystemModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Systemmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Systemmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeSystemModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSystemModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 28u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3491,7 +3307,7 @@ suspend fun readSystemModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 28u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSystemModeAttribute( @@ -3499,35 +3315,37 @@ suspend fun readSystemModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 28u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Systemmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Systemmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3539,47 +3357,41 @@ suspend fun readSystemModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 28u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThermostatRunningModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 30u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readThermostatRunningModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatrunningmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Thermostatrunningmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3589,94 +3401,90 @@ suspend fun readThermostatRunningModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatrunningmode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Thermostatrunningmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartOfWeekAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStartOfWeekAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startofweek attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startofweek attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3686,94 +3494,88 @@ suspend fun readStartOfWeekAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startofweek attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startofweek attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofweeklytransitions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofweeklytransitions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3783,94 +3585,90 @@ suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofweeklytransitions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofweeklytransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfDailyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfDailyTransitionsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofdailytransitions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofdailytransitions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3880,118 +3678,113 @@ suspend fun readNumberOfDailyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofdailytransitions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofdailytransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTemperatureSetpointHoldAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTemperatureSetpointHoldAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointhold attribute not found in response" - } + } + + requireNotNull(attributeData) { "Temperaturesetpointhold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeTemperatureSetpointHoldAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 35u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4013,7 +3806,7 @@ suspend fun readTemperatureSetpointHoldAttribute(): UByte? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureSetpointHoldAttribute( @@ -4021,123 +3814,121 @@ suspend fun readTemperatureSetpointHoldAttribute(): UByte? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointhold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturesetpointhold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTemperatureSetpointHoldDurationAttribute(): TemperatureSetpointHoldDurationAttribute {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTemperatureSetpointHoldDurationAttribute(): + TemperatureSetpointHoldDurationAttribute { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdduration attribute not found in response" + } + + requireNotNull(attributeData) { + "Temperaturesetpointholdduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TemperatureSetpointHoldDurationAttribute(decodedValue) } suspend fun writeTemperatureSetpointHoldDurationAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 36u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4159,7 +3950,7 @@ suspend fun readTemperatureSetpointHoldDurationAttribute(): TemperatureSetpointH throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureSetpointHoldDurationAttribute( @@ -4167,123 +3958,122 @@ suspend fun readTemperatureSetpointHoldDurationAttribute(): TemperatureSetpointH maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TemperatureSetpointHoldDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TemperatureSetpointHoldDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturesetpointholdduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(TemperatureSetpointHoldDurationAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(TemperatureSetpointHoldDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatprogrammingoperationmode attribute not found in response" + } + + requireNotNull(attributeData) { + "Thermostatprogrammingoperationmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeThermostatProgrammingOperationModeAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 37u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4305,7 +4095,7 @@ suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? {val ATTRI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeThermostatProgrammingOperationModeAttribute( @@ -4313,94 +4103,90 @@ suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? {val ATTRI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatprogrammingoperationmode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Thermostatprogrammingoperationmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThermostatRunningStateAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readThermostatRunningStateAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatrunningstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Thermostatrunningstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4410,94 +4196,90 @@ suspend fun readThermostatRunningStateAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatrunningstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Thermostatrunningstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetpointChangeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSetpointChangeSourceAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangesource attribute not found in response" - } + } + + requireNotNull(attributeData) { "Setpointchangesource attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -4507,99 +4289,95 @@ suspend fun readSetpointChangeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangesource attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Setpointchangesource attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangeamount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Setpointchangeamount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SetpointChangeAmountAttribute(decodedValue) } @@ -4609,99 +4387,97 @@ suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SetpointChangeAmountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SetpointChangeAmountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangeamount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Setpointchangeamount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SetpointChangeAmountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SetpointChangeAmountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SetpointChangeAmountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetpointChangeSourceTimestampAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSetpointChangeSourceTimestampAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangesourcetimestamp attribute not found in response" + } + + requireNotNull(attributeData) { + "Setpointchangesourcetimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4711,123 +4487,115 @@ suspend fun readSetpointChangeSourceTimestampAttribute(): UInt? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangesourcetimestamp attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Setpointchangesourcetimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute {val ATTRIBUTE_ID: UInt = 52u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetback attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedsetback attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OccupiedSetbackAttribute(decodedValue) } - suspend fun writeOccupiedSetbackAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOccupiedSetbackAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4849,7 +4617,7 @@ suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOccupiedSetbackAttribute( @@ -4857,104 +4625,100 @@ suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OccupiedSetbackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OccupiedSetbackAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetback attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedsetback attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OccupiedSetbackAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OccupiedSetbackAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OccupiedSetbackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute {val ATTRIBUTE_ID: UInt = 53u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetbackmin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedsetbackmin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OccupiedSetbackMinAttribute(decodedValue) } @@ -4964,104 +4728,100 @@ suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OccupiedSetbackMinAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OccupiedSetbackMinAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetbackmin attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedsetbackmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OccupiedSetbackMinAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OccupiedSetbackMinAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OccupiedSetbackMinAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute {val ATTRIBUTE_ID: UInt = 54u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute { + val ATTRIBUTE_ID: UInt = 54u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetbackmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedsetbackmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OccupiedSetbackMaxAttribute(decodedValue) } @@ -5071,128 +4831,120 @@ suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 54u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OccupiedSetbackMaxAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OccupiedSetbackMaxAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetbackmax attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedsetbackmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OccupiedSetbackMaxAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OccupiedSetbackMaxAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OccupiedSetbackMaxAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute {val ATTRIBUTE_ID: UInt = 55u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute { + val ATTRIBUTE_ID: UInt = 55u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetback attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedsetback attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return UnoccupiedSetbackAttribute(decodedValue) } - suspend fun writeUnoccupiedSetbackAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeUnoccupiedSetbackAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 55u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5214,7 +4966,7 @@ suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute {val AT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnoccupiedSetbackAttribute( @@ -5222,104 +4974,100 @@ suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 55u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UnoccupiedSetbackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UnoccupiedSetbackAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetback attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedsetback attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UnoccupiedSetbackAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UnoccupiedSetbackAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UnoccupiedSetbackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute {val ATTRIBUTE_ID: UInt = 56u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute { + val ATTRIBUTE_ID: UInt = 56u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedsetbackmin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return UnoccupiedSetbackMinAttribute(decodedValue) } @@ -5329,104 +5077,100 @@ suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 56u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UnoccupiedSetbackMinAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UnoccupiedSetbackMinAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmin attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedsetbackmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UnoccupiedSetbackMinAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UnoccupiedSetbackMinAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UnoccupiedSetbackMinAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute {val ATTRIBUTE_ID: UInt = 57u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute { + val ATTRIBUTE_ID: UInt = 57u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedsetbackmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return UnoccupiedSetbackMaxAttribute(decodedValue) } @@ -5436,123 +5180,115 @@ suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 57u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UnoccupiedSetbackMaxAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UnoccupiedSetbackMaxAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmax attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedsetbackmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UnoccupiedSetbackMaxAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UnoccupiedSetbackMaxAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UnoccupiedSetbackMaxAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEmergencyHeatDeltaAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 58u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEmergencyHeatDeltaAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 58u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Emergencyheatdelta attribute not found in response" - } + } + + requireNotNull(attributeData) { "Emergencyheatdelta attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeEmergencyHeatDeltaAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeEmergencyHeatDeltaAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 58u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5574,7 +5310,7 @@ suspend fun readEmergencyHeatDeltaAttribute(): UByte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEmergencyHeatDeltaAttribute( @@ -5582,118 +5318,110 @@ suspend fun readEmergencyHeatDeltaAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 58u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Emergencyheatdelta attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Emergencyheatdelta attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 64u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 64u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Actype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACTypeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 64u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5715,7 +5443,7 @@ suspend fun readACTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 64u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACTypeAttribute( @@ -5723,118 +5451,108 @@ suspend fun readACTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 64u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 64u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Actype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACCapacityAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 65u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACCapacityAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 65u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accapacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accapacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACCapacityAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeACCapacityAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 65u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5856,7 +5574,7 @@ suspend fun readACCapacityAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 65u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACCapacityAttribute( @@ -5864,118 +5582,108 @@ suspend fun readACCapacityAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 65u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accapacity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Accapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACRefrigerantTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 66u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACRefrigerantTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 66u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acrefrigeranttype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acrefrigeranttype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACRefrigerantTypeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACRefrigerantTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 66u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5997,7 +5705,7 @@ suspend fun readACRefrigerantTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACRefrigerantTypeAttribute( @@ -6005,118 +5713,110 @@ suspend fun readACRefrigerantTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 66u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acrefrigeranttype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acrefrigeranttype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACCompressorTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 67u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACCompressorTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 67u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accompressortype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accompressortype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACCompressorTypeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACCompressorTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 67u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6138,7 +5838,7 @@ suspend fun readACCompressorTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 67 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACCompressorTypeAttribute( @@ -6146,118 +5846,110 @@ suspend fun readACCompressorTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 67 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 67u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accompressortype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accompressortype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACErrorCodeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 68u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACErrorCodeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 68u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acerrorcode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acerrorcode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACErrorCodeAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeACErrorCodeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 68u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6279,7 +5971,7 @@ suspend fun readACErrorCodeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 68u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACErrorCodeAttribute( @@ -6287,118 +5979,108 @@ suspend fun readACErrorCodeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 68u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 68u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acerrorcode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Acerrorcode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACLouverPositionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 69u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACLouverPositionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 69u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aclouverposition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Aclouverposition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACLouverPositionAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACLouverPositionAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 69u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6420,7 +6102,7 @@ suspend fun readACLouverPositionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 69 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACLouverPositionAttribute( @@ -6428,99 +6110,95 @@ suspend fun readACLouverPositionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 69 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 69u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aclouverposition attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aclouverposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute {val ATTRIBUTE_ID: UInt = 70u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute { + val ATTRIBUTE_ID: UInt = 70u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accoiltemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accoiltemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ACCoilTemperatureAttribute(decodedValue) } @@ -6530,123 +6208,115 @@ suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 70u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ACCoilTemperatureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ACCoilTemperatureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accoiltemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accoiltemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ACCoilTemperatureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ACCoilTemperatureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ACCoilTemperatureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACCapacityformatAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 71u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACCapacityformatAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 71u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accapacityformat attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accapacityformat attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACCapacityformatAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACCapacityformatAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 71u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6668,7 +6338,7 @@ suspend fun readACCapacityformatAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 71 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACCapacityformatAttribute( @@ -6676,100 +6346,96 @@ suspend fun readACCapacityformatAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 71 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 71u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accapacityformat attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accapacityformat attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPresetTypesAttribute(): PresetTypesAttribute {val ATTRIBUTE_ID: UInt = 72u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPresetTypesAttribute(): PresetTypesAttribute { + val ATTRIBUTE_ID: UInt = 72u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presettypes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Presettypes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return PresetTypesAttribute(decodedValue) } @@ -6779,106 +6445,100 @@ suspend fun readPresetTypesAttribute(): PresetTypesAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 72u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PresetTypesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PresetTypesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presettypes attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Presettypes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(PresetTypesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(PresetTypesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PresetTypesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScheduleTypesAttribute(): ScheduleTypesAttribute {val ATTRIBUTE_ID: UInt = 73u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readScheduleTypesAttribute(): ScheduleTypesAttribute { + val ATTRIBUTE_ID: UInt = 73u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduletypes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scheduletypes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ScheduleTypesAttribute(decodedValue) } @@ -6888,100 +6548,94 @@ suspend fun readScheduleTypesAttribute(): ScheduleTypesAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 73u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ScheduleTypesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ScheduleTypesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduletypes attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Scheduletypes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ScheduleTypesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ScheduleTypesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ScheduleTypesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfPresetsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 74u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfPresetsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 74u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpresets attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofpresets attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -6991,94 +6645,90 @@ suspend fun readNumberOfPresetsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 74u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 74u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpresets attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofpresets attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfSchedulesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 75u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfSchedulesAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 75u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofschedules attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofschedules attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -7088,94 +6738,90 @@ suspend fun readNumberOfSchedulesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 75u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofschedules attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofschedules attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfScheduleTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 76u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfScheduleTransitionsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 76u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofscheduletransitions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofscheduletransitions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -7185,99 +6831,98 @@ suspend fun readNumberOfScheduleTransitionsAttribute(): UByte? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 76u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofscheduletransitions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofscheduletransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfScheduleTransitionPerDayAttribute(): NumberOfScheduleTransitionPerDayAttribute {val ATTRIBUTE_ID: UInt = 77u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfScheduleTransitionPerDayAttribute(): + NumberOfScheduleTransitionPerDayAttribute { + val ATTRIBUTE_ID: UInt = 77u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofscheduletransitionperday attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofscheduletransitionperday attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NumberOfScheduleTransitionPerDayAttribute(decodedValue) } @@ -7287,104 +6932,102 @@ suspend fun readNumberOfScheduleTransitionPerDayAttribute(): NumberOfScheduleTra maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 77u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NumberOfScheduleTransitionPerDayAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NumberOfScheduleTransitionPerDayAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofscheduletransitionperday attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofscheduletransitionperday attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NumberOfScheduleTransitionPerDayAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NumberOfScheduleTransitionPerDayAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePresetHandleAttribute(): ActivePresetHandleAttribute {val ATTRIBUTE_ID: UInt = 78u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePresetHandleAttribute(): ActivePresetHandleAttribute { + val ATTRIBUTE_ID: UInt = 78u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepresethandle attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepresethandle attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActivePresetHandleAttribute(decodedValue) } @@ -7394,104 +7037,100 @@ suspend fun readActivePresetHandleAttribute(): ActivePresetHandleAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 78u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActivePresetHandleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActivePresetHandleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepresethandle attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepresethandle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActivePresetHandleAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActivePresetHandleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActivePresetHandleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveScheduleHandleAttribute(): ActiveScheduleHandleAttribute {val ATTRIBUTE_ID: UInt = 79u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveScheduleHandleAttribute(): ActiveScheduleHandleAttribute { + val ATTRIBUTE_ID: UInt = 79u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeschedulehandle attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activeschedulehandle attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveScheduleHandleAttribute(decodedValue) } @@ -7501,133 +7140,128 @@ suspend fun readActiveScheduleHandleAttribute(): ActiveScheduleHandleAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 79u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveScheduleHandleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveScheduleHandleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeschedulehandle attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activeschedulehandle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveScheduleHandleAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveScheduleHandleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveScheduleHandleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPresetsAttribute(): PresetsAttribute {val ATTRIBUTE_ID: UInt = 80u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPresetsAttribute(): PresetsAttribute { + val ATTRIBUTE_ID: UInt = 80u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presets attribute not found in response" - } + } + + requireNotNull(attributeData) { "Presets attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return PresetsAttribute(decodedValue) } suspend fun writePresetsAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 80u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7649,7 +7283,7 @@ suspend fun readPresetsAttribute(): PresetsAttribute {val ATTRIBUTE_ID: UInt = 8 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePresetsAttribute( @@ -7657,134 +7291,127 @@ suspend fun readPresetsAttribute(): PresetsAttribute {val ATTRIBUTE_ID: UInt = 8 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 80u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PresetsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PresetsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presets attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Presets attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(PresetsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(PresetsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PresetsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSchedulesAttribute(): SchedulesAttribute {val ATTRIBUTE_ID: UInt = 81u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSchedulesAttribute(): SchedulesAttribute { + val ATTRIBUTE_ID: UInt = 81u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Schedules attribute not found in response" - } + } + + requireNotNull(attributeData) { "Schedules attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SchedulesAttribute(decodedValue) } suspend fun writeSchedulesAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 81u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7806,7 +7433,7 @@ suspend fun readSchedulesAttribute(): SchedulesAttribute {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSchedulesAttribute( @@ -7814,100 +7441,94 @@ suspend fun readSchedulesAttribute(): SchedulesAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 81u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SchedulesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SchedulesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Schedules attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Schedules attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SchedulesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SchedulesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SchedulesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPresetsSchedulesEditableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 82u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPresetsSchedulesEditableAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 82u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presetsscheduleseditable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Presetsscheduleseditable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -7917,94 +7538,92 @@ suspend fun readPresetsSchedulesEditableAttribute(): Boolean? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 82u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presetsscheduleseditable attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Presetsscheduleseditable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTemperatureSetpointHoldPolicyAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 83u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTemperatureSetpointHoldPolicyAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 83u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdpolicy attribute not found in response" + } + + requireNotNull(attributeData) { + "Temperaturesetpointholdpolicy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -8014,99 +7633,95 @@ suspend fun readTemperatureSetpointHoldPolicyAttribute(): UByte? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 83u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdpolicy attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturesetpointholdpolicy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetpointHoldExpiryTimestampAttribute(): SetpointHoldExpiryTimestampAttribute {val ATTRIBUTE_ID: UInt = 84u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSetpointHoldExpiryTimestampAttribute(): SetpointHoldExpiryTimestampAttribute { + val ATTRIBUTE_ID: UInt = 84u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointholdexpirytimestamp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Setpointholdexpirytimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SetpointHoldExpiryTimestampAttribute(decodedValue) } @@ -8116,104 +7731,102 @@ suspend fun readSetpointHoldExpiryTimestampAttribute(): SetpointHoldExpiryTimest maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 84u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SetpointHoldExpiryTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SetpointHoldExpiryTimestampAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointholdexpirytimestamp attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Setpointholdexpirytimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(SetpointHoldExpiryTimestampAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(SetpointHoldExpiryTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readQueuedPresetAttribute(): QueuedPresetAttribute {val ATTRIBUTE_ID: UInt = 85u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readQueuedPresetAttribute(): QueuedPresetAttribute { + val ATTRIBUTE_ID: UInt = 85u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Queuedpreset attribute not found in response" - } + } + + requireNotNull(attributeData) { "Queuedpreset attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThermostatClusterQueuedPresetStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ThermostatClusterQueuedPresetStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return QueuedPresetAttribute(decodedValue) } @@ -8223,101 +7836,95 @@ suspend fun readQueuedPresetAttribute(): QueuedPresetAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 85u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(QueuedPresetAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + QueuedPresetAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Queuedpreset attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Queuedpreset attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThermostatClusterQueuedPresetStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(QueuedPresetAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ThermostatClusterQueuedPresetStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(QueuedPresetAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(QueuedPresetAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -8327,45 +7934,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -8373,49 +7985,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -8425,45 +8031,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -8471,49 +8082,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -8523,45 +8128,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -8569,49 +8177,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -8621,45 +8223,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -8667,44 +8272,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -8713,35 +8311,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -8753,44 +8353,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -8799,34 +8392,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8839,7 +8436,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt index f766146a4a3b89..1f5a0777fcb41f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt @@ -17,159 +17,122 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatUserInterfaceConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ThermostatUserInterfaceConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readTemperatureDisplayModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readTemperatureDisplayModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturedisplaymode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Temperaturedisplaymode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } suspend fun writeTemperatureDisplayModeAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -191,7 +154,7 @@ suspend fun readTemperatureDisplayModeAttribute(): UByte {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureDisplayModeAttribute( @@ -199,34 +162,38 @@ suspend fun readTemperatureDisplayModeAttribute(): UByte {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturedisplaymode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturedisplaymode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -239,67 +206,56 @@ suspend fun readTemperatureDisplayModeAttribute(): UByte {val ATTRIBUTE_ID: UInt emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readKeypadLockoutAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readKeypadLockoutAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Keypadlockout attribute not found in response" - } + } + + requireNotNull(attributeData) { "Keypadlockout attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeKeypadLockoutAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeKeypadLockoutAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -321,7 +277,7 @@ suspend fun readKeypadLockoutAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeKeypadLockoutAttribute( @@ -329,35 +285,37 @@ suspend fun readKeypadLockoutAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Keypadlockout attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Keypadlockout attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -369,71 +327,66 @@ suspend fun readKeypadLockoutAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduleprogrammingvisibility attribute not found in response" + } + + requireNotNull(attributeData) { + "Scheduleprogrammingvisibility attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeScheduleProgrammingVisibilityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -455,7 +408,7 @@ suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeScheduleProgrammingVisibilityAttribute( @@ -463,96 +416,92 @@ suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduleprogrammingvisibility attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scheduleprogrammingvisibility attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -562,45 +511,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -608,49 +562,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -660,45 +608,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -706,49 +659,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -758,45 +705,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -804,49 +754,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -856,45 +800,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -902,44 +849,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -948,35 +888,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -988,44 +930,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1034,34 +969,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1074,11 +1013,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(ThermostatUserInterfaceConfigurationCluster::class.java.name) + private val logger = + Logger.getLogger(ThermostatUserInterfaceConfigurationCluster::class.java.name) const val CLUSTER_ID: UInt = 516u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadBorderRouterManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadBorderRouterManagementCluster.kt index 6f01bd3b46855c..fbcfe857b52e8c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadBorderRouterManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadBorderRouterManagementCluster.kt @@ -17,123 +17,92 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadBorderRouterManagementCluster(private val controller: MatterController, private val endpointId: UShort) { - class DatasetResponse( - val dataset: ByteArray - ) -class ActiveDatasetTimestampAttribute( - val value: ULong? - ) +class ThreadBorderRouterManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class DatasetResponse(val dataset: ByteArray) + + class ActiveDatasetTimestampAttribute(val value: ULong?) sealed class ActiveDatasetTimestampAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : ActiveDatasetTimestampAttributeSubscriptionState() - + data class Success(val value: ULong?) : ActiveDatasetTimestampAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveDatasetTimestampAttributeSubscriptionState() - object SubscriptionEstablished : ActiveDatasetTimestampAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ActiveDatasetTimestampAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun getActiveDatasetRequest(timedInvokeTimeout: Duration? = null): DatasetResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -150,39 +119,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_DATASET: Int = 0 var dataset_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_DATASET)) {dataset_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_DATASET)) { + dataset_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (dataset_decoded == null) { - throw IllegalStateException("dataset not found in TLV") + throw IllegalStateException("dataset not found in TLV") } - tlvReader.exitContainer() - return DatasetResponse( - dataset_decoded - ) + return DatasetResponse(dataset_decoded) } suspend fun getPendingDatasetRequest(timedInvokeTimeout: Duration? = null): DatasetResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -199,37 +160,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_DATASET: Int = 0 var dataset_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_DATASET)) {dataset_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_DATASET)) { + dataset_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (dataset_decoded == null) { - throw IllegalStateException("dataset not found in TLV") + throw IllegalStateException("dataset not found in TLV") } - tlvReader.exitContainer() - return DatasetResponse( - dataset_decoded - ) + return DatasetResponse(dataset_decoded) } - suspend fun setActiveDatasetRequest(activeDataset: ByteArray - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setActiveDatasetRequest( + activeDataset: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -239,9 +194,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTIVE_DATASET_REQ), activeDataset) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -255,15 +208,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setPendingDatasetRequest(pendingDataset: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun setPendingDatasetRequest( + pendingDataset: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_PENDING_DATASET_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_PENDING_DATASET_REQ), pendingDataset) + tlvWriter.put(ContextSpecificTag(TAG_PENDING_DATASET_REQ), pendingDataset) tlvWriter.endStructure() val request: InvokeRequest = @@ -276,42 +231,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readBorderRouterNameAttribute(): String {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBorderRouterNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Borderroutername attribute not found in response" - } + } + + requireNotNull(attributeData) { "Borderroutername attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -320,34 +268,38 @@ suspend fun readBorderRouterNameAttribute(): String {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Borderroutername attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Borderroutername attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -360,44 +312,37 @@ suspend fun readBorderRouterNameAttribute(): String {val ATTRIBUTE_ID: UInt = 0u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBorderAgentIDAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBorderAgentIDAttribute(): ByteArray { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Borderagentid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Borderagentid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ByteArray = tlvReader.getByteArray(AnonymousTag) - return decodedValue } @@ -406,35 +351,37 @@ suspend fun readBorderAgentIDAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteArraySubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Borderagentid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Borderagentid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -446,44 +393,37 @@ suspend fun readBorderAgentIDAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 1u emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThreadVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readThreadVersionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Threadversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -492,35 +432,37 @@ suspend fun readThreadVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadversion attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Threadversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -532,44 +474,37 @@ suspend fun readThreadVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInterfaceEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interfaceenabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Interfaceenabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -578,34 +513,38 @@ suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 3 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interfaceenabled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Interfaceenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -618,48 +557,42 @@ suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 3 emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveDatasetTimestampAttribute(): ActiveDatasetTimestampAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveDatasetTimestampAttribute(): ActiveDatasetTimestampAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activedatasettimestamp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activedatasettimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveDatasetTimestampAttribute(decodedValue) } @@ -669,97 +602,93 @@ suspend fun readActiveDatasetTimestampAttribute(): ActiveDatasetTimestampAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveDatasetTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveDatasetTimestampAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activedatasettimestamp attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activedatasettimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveDatasetTimestampAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveDatasetTimestampAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveDatasetTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -769,45 +698,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -815,49 +749,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -867,45 +795,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -913,49 +846,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -965,45 +892,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1011,49 +941,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1063,45 +987,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1109,44 +1036,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1155,35 +1075,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1195,44 +1117,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1241,34 +1156,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1281,7 +1200,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt index 865e7b62d0545d..d4949cb4df2bf6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt @@ -17,366 +17,286 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class ChannelAttribute( - val value: UShort? - ) +class ThreadNetworkDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChannelAttribute(val value: UShort?) sealed class ChannelAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : ChannelAttributeSubscriptionState() - + data class Success(val value: UShort?) : ChannelAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelAttributeSubscriptionState() - object SubscriptionEstablished : ChannelAttributeSubscriptionState() - } -class RoutingRoleAttribute( - val value: UByte? - ) + object SubscriptionEstablished : ChannelAttributeSubscriptionState() + } + + class RoutingRoleAttribute(val value: UByte?) sealed class RoutingRoleAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : RoutingRoleAttributeSubscriptionState() - + data class Success(val value: UByte?) : RoutingRoleAttributeSubscriptionState() + data class Error(val exception: Exception) : RoutingRoleAttributeSubscriptionState() - object SubscriptionEstablished : RoutingRoleAttributeSubscriptionState() - } -class NetworkNameAttribute( - val value: String? - ) + object SubscriptionEstablished : RoutingRoleAttributeSubscriptionState() + } + + class NetworkNameAttribute(val value: String?) sealed class NetworkNameAttributeSubscriptionState { - data class Success( - val value: String? - ) : NetworkNameAttributeSubscriptionState() - + data class Success(val value: String?) : NetworkNameAttributeSubscriptionState() + data class Error(val exception: Exception) : NetworkNameAttributeSubscriptionState() - object SubscriptionEstablished : NetworkNameAttributeSubscriptionState() - } -class PanIdAttribute( - val value: UShort? - ) + object SubscriptionEstablished : NetworkNameAttributeSubscriptionState() + } + + class PanIdAttribute(val value: UShort?) sealed class PanIdAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : PanIdAttributeSubscriptionState() - + data class Success(val value: UShort?) : PanIdAttributeSubscriptionState() + data class Error(val exception: Exception) : PanIdAttributeSubscriptionState() - object SubscriptionEstablished : PanIdAttributeSubscriptionState() - } -class ExtendedPanIdAttribute( - val value: ULong? - ) + object SubscriptionEstablished : PanIdAttributeSubscriptionState() + } + + class ExtendedPanIdAttribute(val value: ULong?) sealed class ExtendedPanIdAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : ExtendedPanIdAttributeSubscriptionState() - + data class Success(val value: ULong?) : ExtendedPanIdAttributeSubscriptionState() + data class Error(val exception: Exception) : ExtendedPanIdAttributeSubscriptionState() - object SubscriptionEstablished : ExtendedPanIdAttributeSubscriptionState() - } -class MeshLocalPrefixAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : ExtendedPanIdAttributeSubscriptionState() + } + + class MeshLocalPrefixAttribute(val value: ByteArray?) sealed class MeshLocalPrefixAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : MeshLocalPrefixAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : MeshLocalPrefixAttributeSubscriptionState() + data class Error(val exception: Exception) : MeshLocalPrefixAttributeSubscriptionState() - object SubscriptionEstablished : MeshLocalPrefixAttributeSubscriptionState() - } -class NeighborTableAttribute( - val value: List - ) + object SubscriptionEstablished : MeshLocalPrefixAttributeSubscriptionState() + } + + class NeighborTableAttribute(val value: List) sealed class NeighborTableAttributeSubscriptionState { - data class Success( - val value: List - ) : NeighborTableAttributeSubscriptionState() - + data class Success(val value: List) : + NeighborTableAttributeSubscriptionState() + data class Error(val exception: Exception) : NeighborTableAttributeSubscriptionState() - object SubscriptionEstablished : NeighborTableAttributeSubscriptionState() - } -class RouteTableAttribute( - val value: List - ) + object SubscriptionEstablished : NeighborTableAttributeSubscriptionState() + } + + class RouteTableAttribute(val value: List) sealed class RouteTableAttributeSubscriptionState { - data class Success( - val value: List - ) : RouteTableAttributeSubscriptionState() - + data class Success(val value: List) : + RouteTableAttributeSubscriptionState() + data class Error(val exception: Exception) : RouteTableAttributeSubscriptionState() - object SubscriptionEstablished : RouteTableAttributeSubscriptionState() - } -class PartitionIdAttribute( - val value: UInt? - ) + object SubscriptionEstablished : RouteTableAttributeSubscriptionState() + } + + class PartitionIdAttribute(val value: UInt?) sealed class PartitionIdAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PartitionIdAttributeSubscriptionState() - + data class Success(val value: UInt?) : PartitionIdAttributeSubscriptionState() + data class Error(val exception: Exception) : PartitionIdAttributeSubscriptionState() - object SubscriptionEstablished : PartitionIdAttributeSubscriptionState() - } -class WeightingAttribute( - val value: UShort? - ) + object SubscriptionEstablished : PartitionIdAttributeSubscriptionState() + } + + class WeightingAttribute(val value: UShort?) sealed class WeightingAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : WeightingAttributeSubscriptionState() - + data class Success(val value: UShort?) : WeightingAttributeSubscriptionState() + data class Error(val exception: Exception) : WeightingAttributeSubscriptionState() - object SubscriptionEstablished : WeightingAttributeSubscriptionState() - } -class DataVersionAttribute( - val value: UShort? - ) + object SubscriptionEstablished : WeightingAttributeSubscriptionState() + } + + class DataVersionAttribute(val value: UShort?) sealed class DataVersionAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : DataVersionAttributeSubscriptionState() - + data class Success(val value: UShort?) : DataVersionAttributeSubscriptionState() + data class Error(val exception: Exception) : DataVersionAttributeSubscriptionState() - object SubscriptionEstablished : DataVersionAttributeSubscriptionState() - } -class StableDataVersionAttribute( - val value: UShort? - ) + object SubscriptionEstablished : DataVersionAttributeSubscriptionState() + } + + class StableDataVersionAttribute(val value: UShort?) sealed class StableDataVersionAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : StableDataVersionAttributeSubscriptionState() - + data class Success(val value: UShort?) : StableDataVersionAttributeSubscriptionState() + data class Error(val exception: Exception) : StableDataVersionAttributeSubscriptionState() - object SubscriptionEstablished : StableDataVersionAttributeSubscriptionState() - } -class LeaderRouterIdAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StableDataVersionAttributeSubscriptionState() + } + + class LeaderRouterIdAttribute(val value: UByte?) sealed class LeaderRouterIdAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : LeaderRouterIdAttributeSubscriptionState() - + data class Success(val value: UByte?) : LeaderRouterIdAttributeSubscriptionState() + data class Error(val exception: Exception) : LeaderRouterIdAttributeSubscriptionState() - object SubscriptionEstablished : LeaderRouterIdAttributeSubscriptionState() - } -class ActiveTimestampAttribute( - val value: ULong? - ) + object SubscriptionEstablished : LeaderRouterIdAttributeSubscriptionState() + } + + class ActiveTimestampAttribute(val value: ULong?) sealed class ActiveTimestampAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : ActiveTimestampAttributeSubscriptionState() - + data class Success(val value: ULong?) : ActiveTimestampAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveTimestampAttributeSubscriptionState() - object SubscriptionEstablished : ActiveTimestampAttributeSubscriptionState() - } -class PendingTimestampAttribute( - val value: ULong? - ) + object SubscriptionEstablished : ActiveTimestampAttributeSubscriptionState() + } + + class PendingTimestampAttribute(val value: ULong?) sealed class PendingTimestampAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : PendingTimestampAttributeSubscriptionState() - + data class Success(val value: ULong?) : PendingTimestampAttributeSubscriptionState() + data class Error(val exception: Exception) : PendingTimestampAttributeSubscriptionState() - object SubscriptionEstablished : PendingTimestampAttributeSubscriptionState() - } -class DelayAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PendingTimestampAttributeSubscriptionState() + } + + class DelayAttribute(val value: UInt?) sealed class DelayAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : DelayAttributeSubscriptionState() - + data class Success(val value: UInt?) : DelayAttributeSubscriptionState() + data class Error(val exception: Exception) : DelayAttributeSubscriptionState() - object SubscriptionEstablished : DelayAttributeSubscriptionState() - } -class SecurityPolicyAttribute( - val value: ThreadNetworkDiagnosticsClusterSecurityPolicy? - ) + object SubscriptionEstablished : DelayAttributeSubscriptionState() + } + + class SecurityPolicyAttribute(val value: ThreadNetworkDiagnosticsClusterSecurityPolicy?) sealed class SecurityPolicyAttributeSubscriptionState { - data class Success( - val value: ThreadNetworkDiagnosticsClusterSecurityPolicy? - ) : SecurityPolicyAttributeSubscriptionState() - + data class Success(val value: ThreadNetworkDiagnosticsClusterSecurityPolicy?) : + SecurityPolicyAttributeSubscriptionState() + data class Error(val exception: Exception) : SecurityPolicyAttributeSubscriptionState() - object SubscriptionEstablished : SecurityPolicyAttributeSubscriptionState() - } -class ChannelPage0MaskAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : SecurityPolicyAttributeSubscriptionState() + } + + class ChannelPage0MaskAttribute(val value: ByteArray?) sealed class ChannelPage0MaskAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : ChannelPage0MaskAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : ChannelPage0MaskAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelPage0MaskAttributeSubscriptionState() - object SubscriptionEstablished : ChannelPage0MaskAttributeSubscriptionState() - } -class OperationalDatasetComponentsAttribute( + object SubscriptionEstablished : ChannelPage0MaskAttributeSubscriptionState() + } + + class OperationalDatasetComponentsAttribute( val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? ) sealed class OperationalDatasetComponentsAttributeSubscriptionState { - data class Success( - val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? - ) : OperationalDatasetComponentsAttributeSubscriptionState() - - data class Error(val exception: Exception) : OperationalDatasetComponentsAttributeSubscriptionState() - - object SubscriptionEstablished : OperationalDatasetComponentsAttributeSubscriptionState() - } -class ActiveNetworkFaultsListAttribute( - val value: List - ) + data class Success(val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents?) : + OperationalDatasetComponentsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + OperationalDatasetComponentsAttributeSubscriptionState() + + object SubscriptionEstablished : OperationalDatasetComponentsAttributeSubscriptionState() + } + + class ActiveNetworkFaultsListAttribute(val value: List) sealed class ActiveNetworkFaultsListAttributeSubscriptionState { - data class Success( - val value: List - ) : ActiveNetworkFaultsListAttributeSubscriptionState() - - data class Error(val exception: Exception) : ActiveNetworkFaultsListAttributeSubscriptionState() - - object SubscriptionEstablished : ActiveNetworkFaultsListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List) : + ActiveNetworkFaultsListAttributeSubscriptionState() + + data class Error(val exception: Exception) : + ActiveNetworkFaultsListAttributeSubscriptionState() + + object SubscriptionEstablished : ActiveNetworkFaultsListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCounts(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -389,46 +309,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readChannelAttribute(): ChannelAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readChannelAttribute(): ChannelAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Channel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ChannelAttribute(decodedValue) } @@ -438,96 +352,90 @@ suspend fun readChannelAttribute(): ChannelAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChannelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChannelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Channel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(ChannelAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ChannelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChannelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routingrole attribute not found in response" - } + } + + requireNotNull(attributeData) { "Routingrole attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return RoutingRoleAttribute(decodedValue) } @@ -537,96 +445,90 @@ suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RoutingRoleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RoutingRoleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routingrole attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Routingrole attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(RoutingRoleAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(RoutingRoleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RoutingRoleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNetworkNameAttribute(): NetworkNameAttribute {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNetworkNameAttribute(): NetworkNameAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networkname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Networkname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NetworkNameAttribute(decodedValue) } @@ -636,96 +538,90 @@ suspend fun readNetworkNameAttribute(): NetworkNameAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NetworkNameAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NetworkNameAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networkname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Networkname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NetworkNameAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NetworkNameAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NetworkNameAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPanIdAttribute(): PanIdAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPanIdAttribute(): PanIdAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Panid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Panid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return PanIdAttribute(decodedValue) } @@ -735,96 +631,90 @@ suspend fun readPanIdAttribute(): PanIdAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PanIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PanIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Panid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Panid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(PanIdAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(PanIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PanIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Extendedpanid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Extendedpanid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ExtendedPanIdAttribute(decodedValue) } @@ -834,96 +724,90 @@ suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ExtendedPanIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ExtendedPanIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Extendedpanid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Extendedpanid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(ExtendedPanIdAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ExtendedPanIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ExtendedPanIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Meshlocalprefix attribute not found in response" - } + } + + requireNotNull(attributeData) { "Meshlocalprefix attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeshLocalPrefixAttribute(decodedValue) } @@ -933,95 +817,91 @@ suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeshLocalPrefixAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeshLocalPrefixAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Meshlocalprefix attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Meshlocalprefix attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(MeshLocalPrefixAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(MeshLocalPrefixAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeshLocalPrefixAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOverrunCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Overruncount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -1031,96 +911,90 @@ suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Overruncount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNeighborTableAttribute(): NeighborTableAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNeighborTableAttribute(): NeighborTableAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neighbortable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Neighbortable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return NeighborTableAttribute(decodedValue) } @@ -1130,45 +1004,53 @@ suspend fun readNeighborTableAttribute(): NeighborTableAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NeighborTableAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NeighborTableAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neighbortable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Neighbortable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(NeighborTableAttributeSubscriptionState.Success(decodedValue)) } @@ -1176,49 +1058,43 @@ suspend fun readNeighborTableAttribute(): NeighborTableAttribute {val ATTRIBUTE_ emit(NeighborTableAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRouteTableAttribute(): RouteTableAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRouteTableAttribute(): RouteTableAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routetable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Routetable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return RouteTableAttribute(decodedValue) } @@ -1228,45 +1104,50 @@ suspend fun readRouteTableAttribute(): RouteTableAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RouteTableAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RouteTableAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routetable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Routetable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } emit(RouteTableAttributeSubscriptionState.Success(decodedValue)) } @@ -1274,48 +1155,42 @@ suspend fun readRouteTableAttribute(): RouteTableAttribute {val ATTRIBUTE_ID: UI emit(RouteTableAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartitionIdAttribute(): PartitionIdAttribute {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPartitionIdAttribute(): PartitionIdAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partitionid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partitionid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return PartitionIdAttribute(decodedValue) } @@ -1325,96 +1200,90 @@ suspend fun readPartitionIdAttribute(): PartitionIdAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PartitionIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PartitionIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partitionid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Partitionid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(PartitionIdAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(PartitionIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PartitionIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWeightingAttribute(): WeightingAttribute {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWeightingAttribute(): WeightingAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Weighting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Weighting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return WeightingAttribute(decodedValue) } @@ -1424,96 +1293,90 @@ suspend fun readWeightingAttribute(): WeightingAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WeightingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WeightingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Weighting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Weighting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(WeightingAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(WeightingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(WeightingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDataVersionAttribute(): DataVersionAttribute {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDataVersionAttribute(): DataVersionAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dataversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dataversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return DataVersionAttribute(decodedValue) } @@ -1523,96 +1386,90 @@ suspend fun readDataVersionAttribute(): DataVersionAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DataVersionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DataVersionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dataversion attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dataversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(DataVersionAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(DataVersionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DataVersionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Stabledataversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Stabledataversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return StableDataVersionAttribute(decodedValue) } @@ -1622,96 +1479,92 @@ suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StableDataVersionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StableDataVersionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Stabledataversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Stabledataversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(StableDataVersionAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StableDataVersionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StableDataVersionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Leaderrouterid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Leaderrouterid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LeaderRouterIdAttribute(decodedValue) } @@ -1721,95 +1574,91 @@ suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LeaderRouterIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LeaderRouterIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Leaderrouterid attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Leaderrouterid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LeaderRouterIdAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LeaderRouterIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LeaderRouterIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDetachedRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDetachedRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Detachedrolecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Detachedrolecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1819,94 +1668,90 @@ suspend fun readDetachedRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Detachedrolecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Detachedrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChildRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readChildRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Childrolecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Childrolecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1916,94 +1761,90 @@ suspend fun readChildRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Childrolecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Childrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRouterRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRouterRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routerrolecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Routerrolecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2013,94 +1854,90 @@ suspend fun readRouterRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routerrolecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Routerrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLeaderRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLeaderRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Leaderrolecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Leaderrolecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2110,94 +1947,90 @@ suspend fun readLeaderRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Leaderrolecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Leaderrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttachAttemptCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttachAttemptCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attachattemptcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attachattemptcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2207,94 +2040,90 @@ suspend fun readAttachAttemptCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attachattemptcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Attachattemptcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartitionIdChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPartitionIdChangeCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partitionidchangecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partitionidchangecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2304,94 +2133,92 @@ suspend fun readPartitionIdChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partitionidchangecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Partitionidchangecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Betterpartitionattachattemptcount attribute not found in response" + } + + requireNotNull(attributeData) { + "Betterpartitionattachattemptcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2401,94 +2228,90 @@ suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort? {val ATTRI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Betterpartitionattachattemptcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Betterpartitionattachattemptcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readParentChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readParentChangeCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Parentchangecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Parentchangecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2498,94 +2321,90 @@ suspend fun readParentChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Parentchangecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Parentchangecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxTotalCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txtotalcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txtotalcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2595,94 +2414,88 @@ suspend fun readTxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 22u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txtotalcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txtotalcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxUnicastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txunicastcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txunicastcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2692,94 +2505,90 @@ suspend fun readTxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 23u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txunicastcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txunicastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxBroadcastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbroadcastcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txbroadcastcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2789,94 +2598,90 @@ suspend fun readTxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbroadcastcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txbroadcastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxAckRequestedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txackrequestedcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txackrequestedcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2886,94 +2691,90 @@ suspend fun readTxAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txackrequestedcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txackrequestedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxAckedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxAckedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txackedcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txackedcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2983,94 +2784,88 @@ suspend fun readTxAckedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txackedcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txackedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxNoAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxNoAckRequestedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txnoackrequestedcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txnoackrequestedcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3080,94 +2875,90 @@ suspend fun readTxNoAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txnoackrequestedcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txnoackrequestedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxDataCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdatacount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txdatacount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3177,94 +2968,88 @@ suspend fun readTxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 28u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdatacount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txdatacount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 29u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxDataPollCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 29u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdatapollcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txdatapollcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3274,94 +3059,90 @@ suspend fun readTxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 29u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 29u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdatapollcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txdatapollcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 30u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxBeaconCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbeaconcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txbeaconcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3371,94 +3152,88 @@ suspend fun readTxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 30u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbeaconcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txbeaconcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 31u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxBeaconRequestCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 31u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbeaconrequestcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txbeaconrequestcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3468,94 +3243,90 @@ suspend fun readTxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 31u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbeaconrequestcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txbeaconrequestcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxOtherCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txothercount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txothercount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3565,94 +3336,88 @@ suspend fun readTxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txothercount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txothercount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxRetryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxRetryCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txretrycount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txretrycount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3662,94 +3427,88 @@ suspend fun readTxRetryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txretrycount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txretrycount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdirectmaxretryexpirycount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txdirectmaxretryexpirycount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3759,94 +3518,92 @@ suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdirectmaxretryexpirycount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txdirectmaxretryexpirycount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txindirectmaxretryexpirycount attribute not found in response" + } + + requireNotNull(attributeData) { + "Txindirectmaxretryexpirycount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3856,94 +3613,90 @@ suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txindirectmaxretryexpirycount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txindirectmaxretryexpirycount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxErrCcaCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxErrCcaCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrccacount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txerrccacount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3953,94 +3706,88 @@ suspend fun readTxErrCcaCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 36u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrccacount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txerrccacount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxErrAbortCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxErrAbortCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrabortcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txerrabortcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4050,94 +3797,90 @@ suspend fun readTxErrAbortCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 37u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrabortcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txerrabortcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxErrBusyChannelCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxErrBusyChannelCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrbusychannelcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txerrbusychannelcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4147,94 +3890,90 @@ suspend fun readTxErrBusyChannelCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrbusychannelcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txerrbusychannelcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 39u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxTotalCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxtotalcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxtotalcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4244,94 +3983,88 @@ suspend fun readRxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 39u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxtotalcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxtotalcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 40u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxUnicastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxunicastcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxunicastcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4341,94 +4074,90 @@ suspend fun readRxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 40u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxunicastcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxunicastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxBroadcastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbroadcastcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxbroadcastcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4438,94 +4167,90 @@ suspend fun readRxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 41u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbroadcastcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxbroadcastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 42u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxDataCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdatacount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxdatacount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4535,94 +4260,88 @@ suspend fun readRxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 42u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdatacount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxdatacount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 43u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxDataPollCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 43u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdatapollcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxdatapollcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4632,94 +4351,90 @@ suspend fun readRxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 43u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 43u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdatapollcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxdatapollcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 44u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxBeaconCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 44u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbeaconcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxbeaconcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4729,94 +4444,88 @@ suspend fun readRxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 44u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 44u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbeaconcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxbeaconcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 45u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxBeaconRequestCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 45u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbeaconrequestcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxbeaconrequestcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4826,94 +4535,90 @@ suspend fun readRxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 45u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbeaconrequestcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxbeaconrequestcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 46u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxOtherCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 46u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxothercount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxothercount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4923,94 +4628,88 @@ suspend fun readRxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 46u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 46u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxothercount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxothercount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxAddressFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 47u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxAddressFilteredCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 47u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxaddressfilteredcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxaddressfilteredcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5020,94 +4719,90 @@ suspend fun readRxAddressFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 47u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxaddressfilteredcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxaddressfilteredcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxDestAddrFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxDestAddrFilteredCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdestaddrfilteredcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxdestaddrfilteredcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5117,94 +4812,90 @@ suspend fun readRxDestAddrFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdestaddrfilteredcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxdestaddrfilteredcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxDuplicatedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxDuplicatedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxduplicatedcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxduplicatedcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5214,94 +4905,90 @@ suspend fun readRxDuplicatedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 49 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxduplicatedcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxduplicatedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrNoFrameCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrNoFrameCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrnoframecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrnoframecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5311,94 +4998,90 @@ suspend fun readRxErrNoFrameCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 50 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrnoframecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxerrnoframecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrUnknownNeighborCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 51u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrUnknownNeighborCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrunknownneighborcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrunknownneighborcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5408,94 +5091,90 @@ suspend fun readRxErrUnknownNeighborCountAttribute(): UInt? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrunknownneighborcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxerrunknownneighborcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 52u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrinvalidsrcaddrcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrinvalidsrcaddrcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5505,94 +5184,90 @@ suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrinvalidsrcaddrcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxerrinvalidsrcaddrcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrSecCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 53u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrSecCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrseccount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrseccount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5602,94 +5277,88 @@ suspend fun readRxErrSecCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 53u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrseccount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxerrseccount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrFcsCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 54u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrFcsCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 54u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrfcscount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrfcscount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5699,94 +5368,88 @@ suspend fun readRxErrFcsCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 54u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 54u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrfcscount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxerrfcscount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 55u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrOtherCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 55u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrothercount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrothercount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5796,99 +5459,95 @@ suspend fun readRxErrOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 55u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 55u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrothercount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxerrothercount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute {val ATTRIBUTE_ID: UInt = 56u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute { + val ATTRIBUTE_ID: UInt = 56u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetimestamp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activetimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveTimestampAttribute(decodedValue) } @@ -5898,104 +5557,100 @@ suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 56u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveTimestampAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetimestamp attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activetimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveTimestampAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveTimestampAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute {val ATTRIBUTE_ID: UInt = 57u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute { + val ATTRIBUTE_ID: UInt = 57u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pendingtimestamp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Pendingtimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PendingTimestampAttribute(decodedValue) } @@ -6005,104 +5660,100 @@ suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 57u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PendingTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PendingTimestampAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pendingtimestamp attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Pendingtimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PendingTimestampAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PendingTimestampAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PendingTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDelayAttribute(): DelayAttribute {val ATTRIBUTE_ID: UInt = 58u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDelayAttribute(): DelayAttribute { + val ATTRIBUTE_ID: UInt = 58u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Delay attribute not found in response" - } + } + + requireNotNull(attributeData) { "Delay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DelayAttribute(decodedValue) } @@ -6112,100 +5763,94 @@ suspend fun readDelayAttribute(): DelayAttribute {val ATTRIBUTE_ID: UInt = 58u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 58u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DelayAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DelayAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Delay attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Delay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DelayAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DelayAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DelayAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute {val ATTRIBUTE_ID: UInt = 59u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute { + val ATTRIBUTE_ID: UInt = 59u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Securitypolicy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Securitypolicy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SecurityPolicyAttribute(decodedValue) } @@ -6215,96 +5860,92 @@ suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 59u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SecurityPolicyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SecurityPolicyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Securitypolicy attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Securitypolicy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(SecurityPolicyAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(SecurityPolicyAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SecurityPolicyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute {val ATTRIBUTE_ID: UInt = 60u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute { + val ATTRIBUTE_ID: UInt = 60u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channelpage0mask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Channelpage0mask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ChannelPage0MaskAttribute(decodedValue) } @@ -6314,96 +5955,92 @@ suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 60u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChannelPage0MaskAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChannelPage0MaskAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channelpage0mask attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Channelpage0mask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(ChannelPage0MaskAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ChannelPage0MaskAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChannelPage0MaskAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetComponentsAttribute {val ATTRIBUTE_ID: UInt = 61u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetComponentsAttribute { + val ATTRIBUTE_ID: UInt = 61u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationaldatasetcomponents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationaldatasetcomponents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } return OperationalDatasetComponentsAttribute(decodedValue) } @@ -6413,97 +6050,98 @@ suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetCompo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 61u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalDatasetComponentsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalDatasetComponentsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationaldatasetcomponents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationaldatasetcomponents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(OperationalDatasetComponentsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(OperationalDatasetComponentsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttribute {val ATTRIBUTE_ID: UInt = 62u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttribute { + val ATTRIBUTE_ID: UInt = 62u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activenetworkfaultslist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activenetworkfaultslist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ActiveNetworkFaultsListAttribute(decodedValue) } @@ -6513,45 +6151,50 @@ suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 62u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveNetworkFaultsListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveNetworkFaultsListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activenetworkfaultslist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activenetworkfaultslist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ActiveNetworkFaultsListAttributeSubscriptionState.Success(decodedValue)) } @@ -6559,49 +6202,43 @@ suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttri emit(ActiveNetworkFaultsListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -6611,45 +6248,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6657,49 +6299,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -6709,45 +6345,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6755,49 +6396,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -6807,45 +6442,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -6853,49 +6491,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -6905,45 +6537,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -6951,44 +6586,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -6997,35 +6625,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7037,44 +6667,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -7083,34 +6706,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7123,7 +6750,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDirectoryCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDirectoryCluster.kt index 94c5ed1b1ab190..8695d588b06d9b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDirectoryCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDirectoryCluster.kt @@ -17,140 +17,107 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDirectoryCluster(private val controller: MatterController, private val endpointId: UShort) { - class OperationalDatasetResponse( - val operationalDataset: ByteArray - ) -class PreferredExtendedPanIDAttribute( - val value: ULong? - ) +class ThreadNetworkDirectoryCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class OperationalDatasetResponse(val operationalDataset: ByteArray) + + class PreferredExtendedPanIDAttribute(val value: ULong?) sealed class PreferredExtendedPanIDAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : PreferredExtendedPanIDAttributeSubscriptionState() - + data class Success(val value: ULong?) : PreferredExtendedPanIDAttributeSubscriptionState() + data class Error(val exception: Exception) : PreferredExtendedPanIDAttributeSubscriptionState() - object SubscriptionEstablished : PreferredExtendedPanIDAttributeSubscriptionState() - } -class ThreadNetworksAttribute( - val value: List - ) + object SubscriptionEstablished : PreferredExtendedPanIDAttributeSubscriptionState() + } + + class ThreadNetworksAttribute(val value: List) sealed class ThreadNetworksAttributeSubscriptionState { - data class Success( - val value: List - ) : ThreadNetworksAttributeSubscriptionState() - + data class Success(val value: List) : + ThreadNetworksAttributeSubscriptionState() + data class Error(val exception: Exception) : ThreadNetworksAttributeSubscriptionState() - object SubscriptionEstablished : ThreadNetworksAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ThreadNetworksAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun addNetwork(operationalDataset: ByteArray - ,timedInvokeTimeout: Duration) { + suspend fun addNetwork(operationalDataset: ByteArray, timedInvokeTimeout: Duration) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_OPERATIONAL_DATASET_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_OPERATIONAL_DATASET_REQ), operationalDataset) + tlvWriter.put(ContextSpecificTag(TAG_OPERATIONAL_DATASET_REQ), operationalDataset) tlvWriter.endStructure() val request: InvokeRequest = @@ -164,15 +131,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun removeNetwork(extendedPanID: ULong - ,timedInvokeTimeout: Duration) { + suspend fun removeNetwork(extendedPanID: ULong, timedInvokeTimeout: Duration) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_EXTENDED_PAN_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_EXTENDED_PAN_I_D_REQ), extendedPanID) + tlvWriter.put(ContextSpecificTag(TAG_EXTENDED_PAN_I_D_REQ), extendedPanID) tlvWriter.endStructure() val request: InvokeRequest = @@ -186,15 +152,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getOperationalDataset(extendedPanID: ULong - ,timedInvokeTimeout: Duration): OperationalDatasetResponse { + suspend fun getOperationalDataset( + extendedPanID: ULong, + timedInvokeTimeout: Duration + ): OperationalDatasetResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_EXTENDED_PAN_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_EXTENDED_PAN_I_D_REQ), extendedPanID) + tlvWriter.put(ContextSpecificTag(TAG_EXTENDED_PAN_I_D_REQ), extendedPanID) tlvWriter.endStructure() val request: InvokeRequest = @@ -211,97 +179,82 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_OPERATIONAL_DATASET: Int = 0 var operationalDataset_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_OPERATIONAL_DATASET)) {operationalDataset_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_OPERATIONAL_DATASET)) { + operationalDataset_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (operationalDataset_decoded == null) { - throw IllegalStateException("operationalDataset not found in TLV") + throw IllegalStateException("operationalDataset not found in TLV") } - tlvReader.exitContainer() - return OperationalDatasetResponse( - operationalDataset_decoded - ) + return OperationalDatasetResponse(operationalDataset_decoded) } -suspend fun readPreferredExtendedPanIDAttribute(): PreferredExtendedPanIDAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPreferredExtendedPanIDAttribute(): PreferredExtendedPanIDAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Preferredextendedpanid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Preferredextendedpanid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return PreferredExtendedPanIDAttribute(decodedValue) } suspend fun writePreferredExtendedPanIDAttribute( value: ULong, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -323,7 +276,7 @@ suspend fun readPreferredExtendedPanIDAttribute(): PreferredExtendedPanIDAttribu throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePreferredExtendedPanIDAttribute( @@ -331,97 +284,93 @@ suspend fun readPreferredExtendedPanIDAttribute(): PreferredExtendedPanIDAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PreferredExtendedPanIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PreferredExtendedPanIDAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Preferredextendedpanid attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Preferredextendedpanid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PreferredExtendedPanIDAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PreferredExtendedPanIDAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PreferredExtendedPanIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThreadNetworksAttribute(): ThreadNetworksAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readThreadNetworksAttribute(): ThreadNetworksAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadnetworks attribute not found in response" - } + } + + requireNotNull(attributeData) { "Threadnetworks attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDirectoryClusterThreadNetworkStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDirectoryClusterThreadNetworkStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ThreadNetworksAttribute(decodedValue) } @@ -431,45 +380,52 @@ suspend fun readThreadNetworksAttribute(): ThreadNetworksAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ThreadNetworksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ThreadNetworksAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadnetworks attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Threadnetworks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDirectoryClusterThreadNetworkStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ThreadNetworkDirectoryClusterThreadNetworkStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } emit(ThreadNetworksAttributeSubscriptionState.Success(decodedValue)) } @@ -477,44 +433,37 @@ suspend fun readThreadNetworksAttribute(): ThreadNetworksAttribute {val ATTRIBUT emit(ThreadNetworksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThreadNetworkTableSizeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readThreadNetworkTableSizeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadnetworktablesize attribute not found in response" - } + } + + requireNotNull(attributeData) { "Threadnetworktablesize attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -523,34 +472,38 @@ suspend fun readThreadNetworkTableSizeAttribute(): UByte {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadnetworktablesize attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Threadnetworktablesize attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -563,49 +516,43 @@ suspend fun readThreadNetworkTableSizeAttribute(): UByte {val ATTRIBUTE_ID: UInt emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -615,45 +562,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -661,49 +613,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -713,45 +659,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -759,49 +710,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -811,45 +756,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -857,49 +805,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -909,45 +851,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -955,44 +900,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1001,35 +939,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1041,44 +981,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1087,34 +1020,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1127,7 +1064,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt index 0a6b84266fe5f8..c16c37cdb0d766 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt @@ -17,172 +17,130 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeFormatLocalizationCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedCalendarTypesAttribute( - val value: List? - ) +class TimeFormatLocalizationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedCalendarTypesAttribute(val value: List?) sealed class SupportedCalendarTypesAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedCalendarTypesAttributeSubscriptionState() - + data class Success(val value: List?) : + SupportedCalendarTypesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedCalendarTypesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedCalendarTypesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedCalendarTypesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readHourFormatAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readHourFormatAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hourformat attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hourformat attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeHourFormatAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeHourFormatAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -204,7 +162,7 @@ suspend fun readHourFormatAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeHourFormatAttribute( @@ -212,35 +170,37 @@ suspend fun readHourFormatAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hourformat attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Hourformat attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -252,71 +212,61 @@ suspend fun readHourFormatAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveCalendarTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveCalendarTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecalendartype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activecalendartype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeActiveCalendarTypeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeActiveCalendarTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -338,7 +288,7 @@ suspend fun readActiveCalendarTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeActiveCalendarTypeAttribute( @@ -346,100 +296,96 @@ suspend fun readActiveCalendarTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecalendartype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activecalendartype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedcalendartypes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedcalendartypes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedCalendarTypesAttribute(decodedValue) } @@ -449,102 +395,98 @@ suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedCalendarTypesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedCalendarTypesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedcalendartypes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedcalendartypes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SupportedCalendarTypesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SupportedCalendarTypesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SupportedCalendarTypesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -554,45 +496,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -600,49 +547,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -652,45 +593,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -698,49 +644,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -750,45 +690,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -796,49 +739,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -848,45 +785,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -894,44 +834,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -940,35 +873,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -980,44 +915,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1026,34 +954,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1066,7 +998,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt index 6310128a0314e5..13edfff80a046d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt @@ -17,187 +17,145 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationCluster(private val controller: MatterController, private val endpointId: UShort) { - class SetTimeZoneResponse( - val DSTOffsetRequired: Boolean - ) -class UTCTimeAttribute( - val value: ULong? - ) +class TimeSynchronizationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SetTimeZoneResponse(val DSTOffsetRequired: Boolean) + + class UTCTimeAttribute(val value: ULong?) sealed class UTCTimeAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : UTCTimeAttributeSubscriptionState() - + data class Success(val value: ULong?) : UTCTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : UTCTimeAttributeSubscriptionState() - object SubscriptionEstablished : UTCTimeAttributeSubscriptionState() - } -class TrustedTimeSourceAttribute( - val value: TimeSynchronizationClusterTrustedTimeSourceStruct? - ) + object SubscriptionEstablished : UTCTimeAttributeSubscriptionState() + } + + class TrustedTimeSourceAttribute(val value: TimeSynchronizationClusterTrustedTimeSourceStruct?) sealed class TrustedTimeSourceAttributeSubscriptionState { - data class Success( - val value: TimeSynchronizationClusterTrustedTimeSourceStruct? - ) : TrustedTimeSourceAttributeSubscriptionState() - + data class Success(val value: TimeSynchronizationClusterTrustedTimeSourceStruct?) : + TrustedTimeSourceAttributeSubscriptionState() + data class Error(val exception: Exception) : TrustedTimeSourceAttributeSubscriptionState() - object SubscriptionEstablished : TrustedTimeSourceAttributeSubscriptionState() - } -class DefaultNTPAttribute( - val value: String? - ) + object SubscriptionEstablished : TrustedTimeSourceAttributeSubscriptionState() + } + + class DefaultNTPAttribute(val value: String?) sealed class DefaultNTPAttributeSubscriptionState { - data class Success( - val value: String? - ) : DefaultNTPAttributeSubscriptionState() - + data class Success(val value: String?) : DefaultNTPAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultNTPAttributeSubscriptionState() - object SubscriptionEstablished : DefaultNTPAttributeSubscriptionState() - } -class TimeZoneAttribute( - val value: List? - ) + object SubscriptionEstablished : DefaultNTPAttributeSubscriptionState() + } + + class TimeZoneAttribute(val value: List?) sealed class TimeZoneAttributeSubscriptionState { - data class Success( - val value: List? - ) : TimeZoneAttributeSubscriptionState() - + data class Success(val value: List?) : + TimeZoneAttributeSubscriptionState() + data class Error(val exception: Exception) : TimeZoneAttributeSubscriptionState() - object SubscriptionEstablished : TimeZoneAttributeSubscriptionState() - } -class DSTOffsetAttribute( - val value: List? - ) + object SubscriptionEstablished : TimeZoneAttributeSubscriptionState() + } + + class DSTOffsetAttribute(val value: List?) sealed class DSTOffsetAttributeSubscriptionState { - data class Success( - val value: List? - ) : DSTOffsetAttributeSubscriptionState() - + data class Success(val value: List?) : + DSTOffsetAttributeSubscriptionState() + data class Error(val exception: Exception) : DSTOffsetAttributeSubscriptionState() - object SubscriptionEstablished : DSTOffsetAttributeSubscriptionState() - } -class LocalTimeAttribute( - val value: ULong? - ) + object SubscriptionEstablished : DSTOffsetAttributeSubscriptionState() + } + + class LocalTimeAttribute(val value: ULong?) sealed class LocalTimeAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : LocalTimeAttributeSubscriptionState() - + data class Success(val value: ULong?) : LocalTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : LocalTimeAttributeSubscriptionState() - object SubscriptionEstablished : LocalTimeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LocalTimeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setUTCTime(UTCTime: ULong - ,granularity: UByte - ,timeSource: UByte? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setUTCTime( + UTCTime: ULong, + granularity: UByte, + timeSource: UByte?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -210,9 +168,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GRANULARITY_REQ), granularity) val TAG_TIME_SOURCE_REQ: Int = 2 - timeSource?.let { - tlvWriter.put(ContextSpecificTag(TAG_TIME_SOURCE_REQ), timeSource) - } + timeSource?.let { tlvWriter.put(ContextSpecificTag(TAG_TIME_SOURCE_REQ), timeSource) } tlvWriter.endStructure() val request: InvokeRequest = @@ -226,8 +182,10 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTrustedTimeSource(trustedTimeSource: TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setTrustedTimeSource( + trustedTimeSource: TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -236,7 +194,7 @@ class AttributeListAttribute( val TAG_TRUSTED_TIME_SOURCE_REQ: Int = 0 trustedTimeSource?.let { trustedTimeSource.toTlv(ContextSpecificTag(TAG_TRUSTED_TIME_SOURCE_REQ), tlvWriter) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -250,8 +208,10 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTimeZone(timeZone: List - ,timedInvokeTimeout: Duration? = null): SetTimeZoneResponse { + suspend fun setTimeZone( + timeZone: List, + timedInvokeTimeout: Duration? = null + ): SetTimeZoneResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -259,10 +219,10 @@ class AttributeListAttribute( val TAG_TIME_ZONE_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_TIME_ZONE_REQ)) - for (item in timeZone.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in timeZone.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -279,36 +239,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_D_S_T_OFFSET_REQUIRED: Int = 0 var DSTOffsetRequired_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_D_S_T_OFFSET_REQUIRED)) {DSTOffsetRequired_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_D_S_T_OFFSET_REQUIRED)) { + DSTOffsetRequired_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (DSTOffsetRequired_decoded == null) { - throw IllegalStateException("DSTOffsetRequired not found in TLV") + throw IllegalStateException("DSTOffsetRequired not found in TLV") } - tlvReader.exitContainer() - return SetTimeZoneResponse( - DSTOffsetRequired_decoded - ) + return SetTimeZoneResponse(DSTOffsetRequired_decoded) } - suspend fun setDSTOffset(DSTOffset: List - ,timedInvokeTimeout: Duration? = null) { + suspend fun setDSTOffset( + DSTOffset: List, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -316,10 +270,10 @@ class AttributeListAttribute( val TAG_D_S_T_OFFSET_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_D_S_T_OFFSET_REQ)) - for (item in DSTOffset.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in DSTOffset.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -333,17 +287,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setDefaultNTP(defaultNTP: String? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setDefaultNTP(defaultNTP: String?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DEFAULT_N_T_P_REQ: Int = 0 - defaultNTP?.let { - tlvWriter.put(ContextSpecificTag(TAG_DEFAULT_N_T_P_REQ), defaultNTP) - } + defaultNTP?.let { tlvWriter.put(ContextSpecificTag(TAG_DEFAULT_N_T_P_REQ), defaultNTP) } tlvWriter.endStructure() val request: InvokeRequest = @@ -356,46 +307,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readUTCTimeAttribute(): UTCTimeAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUTCTimeAttribute(): UTCTimeAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Utctime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Utctime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return UTCTimeAttribute(decodedValue) } @@ -405,92 +350,85 @@ suspend fun readUTCTimeAttribute(): UTCTimeAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UTCTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UTCTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Utctime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Utctime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UTCTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UTCTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UTCTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGranularityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGranularityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Granularity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Granularity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -499,35 +437,37 @@ suspend fun readGranularityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Granularity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Granularity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -539,47 +479,41 @@ suspend fun readGranularityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeSourceAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timesource attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timesource attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -589,99 +523,93 @@ suspend fun readTimeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timesource attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Timesource attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Trustedtimesource attribute not found in response" - } + } + + requireNotNull(attributeData) { "Trustedtimesource attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TrustedTimeSourceAttribute(decodedValue) } @@ -691,104 +619,100 @@ suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TrustedTimeSourceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TrustedTimeSourceAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Trustedtimesource attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Trustedtimesource attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(TrustedTimeSourceAttributeSubscriptionState.Success(it)) - } - + val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(TrustedTimeSourceAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TrustedTimeSourceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultntp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultntp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DefaultNTPAttribute(decodedValue) } @@ -798,105 +722,99 @@ suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DefaultNTPAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DefaultNTPAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultntp attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Defaultntp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DefaultNTPAttributeSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DefaultNTPAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DefaultNTPAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeZoneAttribute(): TimeZoneAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeZoneAttribute(): TimeZoneAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezone attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timezone attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return TimeZoneAttribute(decodedValue) } @@ -906,106 +824,100 @@ suspend fun readTimeZoneAttribute(): TimeZoneAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TimeZoneAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TimeZoneAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezone attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Timezone attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(TimeZoneAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(TimeZoneAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TimeZoneAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dstoffset attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dstoffset attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return DSTOffsetAttribute(decodedValue) } @@ -1015,105 +927,99 @@ suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DSTOffsetAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DSTOffsetAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dstoffset attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dstoffset attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(DSTOffsetAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(DSTOffsetAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DSTOffsetAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocalTimeAttribute(): LocalTimeAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLocalTimeAttribute(): LocalTimeAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LocalTimeAttribute(decodedValue) } @@ -1123,99 +1029,93 @@ suspend fun readLocalTimeAttribute(): LocalTimeAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LocalTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LocalTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Localtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LocalTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LocalTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LocalTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeZoneDatabaseAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeZoneDatabaseAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezonedatabase attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timezonedatabase attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1225,94 +1125,90 @@ suspend fun readTimeZoneDatabaseAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezonedatabase attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Timezonedatabase attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNTPServerAvailableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNTPServerAvailableAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ntpserveravailable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ntpserveravailable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1322,94 +1218,90 @@ suspend fun readNTPServerAvailableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ntpserveravailable attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ntpserveravailable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeZoneListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeZoneListMaxSizeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezonelistmaxsize attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timezonelistmaxsize attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1419,94 +1311,90 @@ suspend fun readTimeZoneListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezonelistmaxsize attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Timezonelistmaxsize attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDSTOffsetListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDSTOffsetListMaxSizeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dstoffsetlistmaxsize attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dstoffsetlistmaxsize attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1516,94 +1404,90 @@ suspend fun readDSTOffsetListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dstoffsetlistmaxsize attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dstoffsetlistmaxsize attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportsDNSResolveAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 12u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportsDNSResolveAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportsdnsresolve attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportsdnsresolve attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1613,96 +1497,92 @@ suspend fun readSupportsDNSResolveAttribute(): Boolean? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportsdnsresolve attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportsdnsresolve attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1712,45 +1592,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1758,49 +1643,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1810,45 +1689,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1856,49 +1740,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1908,45 +1786,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1954,49 +1835,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2006,45 +1881,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2052,44 +1930,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2098,35 +1969,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2138,44 +2011,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2184,34 +2050,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2224,7 +2094,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt index e974a2ed351918..c019d26a8a29bf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt @@ -17,110 +17,78 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimerCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class TimerCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setTimer(newTime: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun setTimer(newTime: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_TIME_REQ), newTime) + tlvWriter.put(ContextSpecificTag(TAG_NEW_TIME_REQ), newTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -138,7 +106,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -152,15 +120,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addTime(additionalTime: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun addTime(additionalTime: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ADDITIONAL_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ADDITIONAL_TIME_REQ), additionalTime) + tlvWriter.put(ContextSpecificTag(TAG_ADDITIONAL_TIME_REQ), additionalTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -174,15 +141,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun reduceTime(timeReduction: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun reduceTime(timeReduction: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TIME_REDUCTION_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TIME_REDUCTION_REQ), timeReduction) + tlvWriter.put(ContextSpecificTag(TAG_TIME_REDUCTION_REQ), timeReduction) tlvWriter.endStructure() val request: InvokeRequest = @@ -195,42 +161,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readSetTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSetTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Settime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Settime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -239,35 +198,37 @@ suspend fun readSetTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Settime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Settime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -279,44 +240,37 @@ suspend fun readSetTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeRemainingAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeRemainingAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timeremaining attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timeremaining attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -325,35 +279,37 @@ suspend fun readTimeRemainingAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timeremaining attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Timeremaining attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -365,44 +321,37 @@ suspend fun readTimeRemainingAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimerStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimerStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timerstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timerstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -411,35 +360,37 @@ suspend fun readTimerStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timerstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Timerstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -451,49 +402,43 @@ suspend fun readTimerStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -503,45 +448,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -549,49 +499,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -601,45 +545,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -647,49 +596,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -699,45 +642,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -745,49 +691,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -797,45 +737,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -843,44 +786,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -889,35 +825,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -929,44 +867,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -975,34 +906,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1015,7 +950,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt index acddad214ee5bc..5ff5251fad8295 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,14 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(TotalVolatileOrganicCompoundsConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger( + TotalVolatileOrganicCompoundsConcentrationMeasurementCluster::class.java.name + ) const val CLUSTER_ID: UInt = 1070u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt index 7d5cb6ca7abba9..36c750385a9bd6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt @@ -17,163 +17,124 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitLocalizationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class UnitLocalizationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readTemperatureUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readTemperatureUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperatureunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Temperatureunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeTemperatureUnitAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeTemperatureUnitAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -195,7 +156,7 @@ suspend fun readTemperatureUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureUnitAttribute( @@ -203,96 +164,92 @@ suspend fun readTemperatureUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperatureunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperatureunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -302,45 +259,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -348,49 +310,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -400,45 +356,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -446,49 +407,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -498,45 +453,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -544,49 +502,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -596,45 +548,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -642,44 +597,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -688,35 +636,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -728,44 +678,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -774,34 +717,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -814,7 +761,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt index b48f040d437072..dd71f008893fa9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt @@ -17,719 +17,573 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.LongSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.ShortSubscriptionState +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class UnitTestingCluster(private val controller: MatterController, private val endpointId: UShort) { - class TestSpecificResponse( - val returnValue: UByte - ) + class TestSpecificResponse(val returnValue: UByte) - class TestAddArgumentsResponse( - val returnValue: UByte - ) + class TestAddArgumentsResponse(val returnValue: UByte) - class TestSimpleArgumentResponse( - val returnValue: Boolean - ) + class TestSimpleArgumentResponse(val returnValue: Boolean) class TestStructArrayArgumentResponse( - val arg1: List, - val arg2: List, - val arg3: List, - val arg4: List, - val arg5: UByte, + val arg1: List, + val arg2: List, + val arg3: List, + val arg4: List, + val arg5: UByte, val arg6: Boolean ) - class BooleanResponse( - val value: Boolean - ) + class BooleanResponse(val value: Boolean) - class TestListInt8UReverseResponse( - val arg1: List - ) + class TestListInt8UReverseResponse(val arg1: List) - class TestEnumsResponse( - val arg1: UShort, - val arg2: UByte - ) + class TestEnumsResponse(val arg1: UShort, val arg2: UByte) class TestNullableOptionalResponse( - val wasPresent: Boolean, - val wasNull: Boolean?, - val value: UByte?, + val wasPresent: Boolean, + val wasNull: Boolean?, + val value: UByte?, val originalValue: UByte? ) class TestComplexNullableOptionalResponse( - val nullableIntWasNull: Boolean, - val nullableIntValue: UShort?, - val optionalIntWasPresent: Boolean, - val optionalIntValue: UShort?, - val nullableOptionalIntWasPresent: Boolean, - val nullableOptionalIntWasNull: Boolean?, - val nullableOptionalIntValue: UShort?, - val nullableStringWasNull: Boolean, - val nullableStringValue: String?, - val optionalStringWasPresent: Boolean, - val optionalStringValue: String?, - val nullableOptionalStringWasPresent: Boolean, - val nullableOptionalStringWasNull: Boolean?, - val nullableOptionalStringValue: String?, - val nullableStructWasNull: Boolean, - val nullableStructValue: UnitTestingClusterSimpleStruct?, - val optionalStructWasPresent: Boolean, - val optionalStructValue: UnitTestingClusterSimpleStruct?, - val nullableOptionalStructWasPresent: Boolean, - val nullableOptionalStructWasNull: Boolean?, - val nullableOptionalStructValue: UnitTestingClusterSimpleStruct?, - val nullableListWasNull: Boolean, - val nullableListValue: List?, - val optionalListWasPresent: Boolean, - val optionalListValue: List?, - val nullableOptionalListWasPresent: Boolean, - val nullableOptionalListWasNull: Boolean?, + val nullableIntWasNull: Boolean, + val nullableIntValue: UShort?, + val optionalIntWasPresent: Boolean, + val optionalIntValue: UShort?, + val nullableOptionalIntWasPresent: Boolean, + val nullableOptionalIntWasNull: Boolean?, + val nullableOptionalIntValue: UShort?, + val nullableStringWasNull: Boolean, + val nullableStringValue: String?, + val optionalStringWasPresent: Boolean, + val optionalStringValue: String?, + val nullableOptionalStringWasPresent: Boolean, + val nullableOptionalStringWasNull: Boolean?, + val nullableOptionalStringValue: String?, + val nullableStructWasNull: Boolean, + val nullableStructValue: UnitTestingClusterSimpleStruct?, + val optionalStructWasPresent: Boolean, + val optionalStructValue: UnitTestingClusterSimpleStruct?, + val nullableOptionalStructWasPresent: Boolean, + val nullableOptionalStructWasNull: Boolean?, + val nullableOptionalStructValue: UnitTestingClusterSimpleStruct?, + val nullableListWasNull: Boolean, + val nullableListValue: List?, + val optionalListWasPresent: Boolean, + val optionalListValue: List?, + val nullableOptionalListWasPresent: Boolean, + val nullableOptionalListWasNull: Boolean?, val nullableOptionalListValue: List? ) - class SimpleStructResponse( - val arg1: UnitTestingClusterSimpleStruct - ) + class SimpleStructResponse(val arg1: UnitTestingClusterSimpleStruct) - class TestEmitTestEventResponse( - val value: ULong - ) + class TestEmitTestEventResponse(val value: ULong) - class TestEmitTestFabricScopedEventResponse( - val value: ULong - ) + class TestEmitTestFabricScopedEventResponse(val value: ULong) - class TestBatchHelperResponse( - val buffer: ByteArray - ) + class TestBatchHelperResponse(val buffer: ByteArray) - class TestDifferentVendorMeiResponse( - val arg1: UByte, - val eventNumber: ULong - ) -class ListInt8uAttribute( - val value: List - ) + class TestDifferentVendorMeiResponse(val arg1: UByte, val eventNumber: ULong) + + class ListInt8uAttribute(val value: List) sealed class ListInt8uAttributeSubscriptionState { - data class Success( - val value: List - ) : ListInt8uAttributeSubscriptionState() - + data class Success(val value: List) : ListInt8uAttributeSubscriptionState() + data class Error(val exception: Exception) : ListInt8uAttributeSubscriptionState() - object SubscriptionEstablished : ListInt8uAttributeSubscriptionState() - } -class ListOctetStringAttribute( - val value: List - ) + object SubscriptionEstablished : ListInt8uAttributeSubscriptionState() + } + + class ListOctetStringAttribute(val value: List) sealed class ListOctetStringAttributeSubscriptionState { - data class Success( - val value: List - ) : ListOctetStringAttributeSubscriptionState() - + data class Success(val value: List) : ListOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : ListOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : ListOctetStringAttributeSubscriptionState() - } -class ListStructOctetStringAttribute( - val value: List - ) + object SubscriptionEstablished : ListOctetStringAttributeSubscriptionState() + } + + class ListStructOctetStringAttribute(val value: List) sealed class ListStructOctetStringAttributeSubscriptionState { - data class Success( - val value: List - ) : ListStructOctetStringAttributeSubscriptionState() - + data class Success(val value: List) : + ListStructOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : ListStructOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : ListStructOctetStringAttributeSubscriptionState() - } -class ListNullablesAndOptionalsStructAttribute( + object SubscriptionEstablished : ListStructOctetStringAttributeSubscriptionState() + } + + class ListNullablesAndOptionalsStructAttribute( val value: List ) sealed class ListNullablesAndOptionalsStructAttributeSubscriptionState { - data class Success( - val value: List - ) : ListNullablesAndOptionalsStructAttributeSubscriptionState() - - data class Error(val exception: Exception) : ListNullablesAndOptionalsStructAttributeSubscriptionState() - - object SubscriptionEstablished : ListNullablesAndOptionalsStructAttributeSubscriptionState() - } -class StructAttrAttribute( - val value: UnitTestingClusterSimpleStruct - ) + data class Success(val value: List) : + ListNullablesAndOptionalsStructAttributeSubscriptionState() + + data class Error(val exception: Exception) : + ListNullablesAndOptionalsStructAttributeSubscriptionState() + + object SubscriptionEstablished : ListNullablesAndOptionalsStructAttributeSubscriptionState() + } + + class StructAttrAttribute(val value: UnitTestingClusterSimpleStruct) sealed class StructAttrAttributeSubscriptionState { - data class Success( - val value: UnitTestingClusterSimpleStruct - ) : StructAttrAttributeSubscriptionState() - + data class Success(val value: UnitTestingClusterSimpleStruct) : + StructAttrAttributeSubscriptionState() + data class Error(val exception: Exception) : StructAttrAttributeSubscriptionState() - object SubscriptionEstablished : StructAttrAttributeSubscriptionState() - } -class ListLongOctetStringAttribute( - val value: List - ) + object SubscriptionEstablished : StructAttrAttributeSubscriptionState() + } + + class ListLongOctetStringAttribute(val value: List) sealed class ListLongOctetStringAttributeSubscriptionState { - data class Success( - val value: List - ) : ListLongOctetStringAttributeSubscriptionState() - + data class Success(val value: List) : + ListLongOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : ListLongOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : ListLongOctetStringAttributeSubscriptionState() - } -class ListFabricScopedAttribute( - val value: List - ) + object SubscriptionEstablished : ListLongOctetStringAttributeSubscriptionState() + } + + class ListFabricScopedAttribute(val value: List) sealed class ListFabricScopedAttributeSubscriptionState { - data class Success( - val value: List - ) : ListFabricScopedAttributeSubscriptionState() - + data class Success(val value: List) : + ListFabricScopedAttributeSubscriptionState() + data class Error(val exception: Exception) : ListFabricScopedAttributeSubscriptionState() - object SubscriptionEstablished : ListFabricScopedAttributeSubscriptionState() - } -class NullableBooleanAttribute( - val value: Boolean? - ) + object SubscriptionEstablished : ListFabricScopedAttributeSubscriptionState() + } + + class NullableBooleanAttribute(val value: Boolean?) sealed class NullableBooleanAttributeSubscriptionState { - data class Success( - val value: Boolean? - ) : NullableBooleanAttributeSubscriptionState() - + data class Success(val value: Boolean?) : NullableBooleanAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBooleanAttributeSubscriptionState() - object SubscriptionEstablished : NullableBooleanAttributeSubscriptionState() - } -class NullableBitmap8Attribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableBooleanAttributeSubscriptionState() + } + + class NullableBitmap8Attribute(val value: UByte?) sealed class NullableBitmap8AttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableBitmap8AttributeSubscriptionState() - + data class Success(val value: UByte?) : NullableBitmap8AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap8AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap8AttributeSubscriptionState() - } -class NullableBitmap16Attribute( - val value: UShort? - ) + object SubscriptionEstablished : NullableBitmap8AttributeSubscriptionState() + } + + class NullableBitmap16Attribute(val value: UShort?) sealed class NullableBitmap16AttributeSubscriptionState { - data class Success( - val value: UShort? - ) : NullableBitmap16AttributeSubscriptionState() - + data class Success(val value: UShort?) : NullableBitmap16AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap16AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap16AttributeSubscriptionState() - } -class NullableBitmap32Attribute( - val value: UInt? - ) + object SubscriptionEstablished : NullableBitmap16AttributeSubscriptionState() + } + + class NullableBitmap32Attribute(val value: UInt?) sealed class NullableBitmap32AttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NullableBitmap32AttributeSubscriptionState() - + data class Success(val value: UInt?) : NullableBitmap32AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap32AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap32AttributeSubscriptionState() - } -class NullableBitmap64Attribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableBitmap32AttributeSubscriptionState() + } + + class NullableBitmap64Attribute(val value: ULong?) sealed class NullableBitmap64AttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableBitmap64AttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableBitmap64AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap64AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap64AttributeSubscriptionState() - } -class NullableInt8uAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableBitmap64AttributeSubscriptionState() + } + + class NullableInt8uAttribute(val value: UByte?) sealed class NullableInt8uAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableInt8uAttributeSubscriptionState() - + data class Success(val value: UByte?) : NullableInt8uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt8uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt8uAttributeSubscriptionState() - } -class NullableInt16uAttribute( - val value: UShort? - ) + object SubscriptionEstablished : NullableInt8uAttributeSubscriptionState() + } + + class NullableInt16uAttribute(val value: UShort?) sealed class NullableInt16uAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : NullableInt16uAttributeSubscriptionState() - + data class Success(val value: UShort?) : NullableInt16uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt16uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt16uAttributeSubscriptionState() - } -class NullableInt24uAttribute( - val value: UInt? - ) + object SubscriptionEstablished : NullableInt16uAttributeSubscriptionState() + } + + class NullableInt24uAttribute(val value: UInt?) sealed class NullableInt24uAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NullableInt24uAttributeSubscriptionState() - + data class Success(val value: UInt?) : NullableInt24uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt24uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt24uAttributeSubscriptionState() - } -class NullableInt32uAttribute( - val value: UInt? - ) + object SubscriptionEstablished : NullableInt24uAttributeSubscriptionState() + } + + class NullableInt32uAttribute(val value: UInt?) sealed class NullableInt32uAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NullableInt32uAttributeSubscriptionState() - + data class Success(val value: UInt?) : NullableInt32uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt32uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt32uAttributeSubscriptionState() - } -class NullableInt40uAttribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableInt32uAttributeSubscriptionState() + } + + class NullableInt40uAttribute(val value: ULong?) sealed class NullableInt40uAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableInt40uAttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableInt40uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt40uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt40uAttributeSubscriptionState() - } -class NullableInt48uAttribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableInt40uAttributeSubscriptionState() + } + + class NullableInt48uAttribute(val value: ULong?) sealed class NullableInt48uAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableInt48uAttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableInt48uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt48uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt48uAttributeSubscriptionState() - } -class NullableInt56uAttribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableInt48uAttributeSubscriptionState() + } + + class NullableInt56uAttribute(val value: ULong?) sealed class NullableInt56uAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableInt56uAttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableInt56uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt56uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt56uAttributeSubscriptionState() - } -class NullableInt64uAttribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableInt56uAttributeSubscriptionState() + } + + class NullableInt64uAttribute(val value: ULong?) sealed class NullableInt64uAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableInt64uAttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableInt64uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt64uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt64uAttributeSubscriptionState() - } -class NullableInt8sAttribute( - val value: Byte? - ) + object SubscriptionEstablished : NullableInt64uAttributeSubscriptionState() + } + + class NullableInt8sAttribute(val value: Byte?) sealed class NullableInt8sAttributeSubscriptionState { - data class Success( - val value: Byte? - ) : NullableInt8sAttributeSubscriptionState() - + data class Success(val value: Byte?) : NullableInt8sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt8sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt8sAttributeSubscriptionState() - } -class NullableInt16sAttribute( - val value: Short? - ) + object SubscriptionEstablished : NullableInt8sAttributeSubscriptionState() + } + + class NullableInt16sAttribute(val value: Short?) sealed class NullableInt16sAttributeSubscriptionState { - data class Success( - val value: Short? - ) : NullableInt16sAttributeSubscriptionState() - + data class Success(val value: Short?) : NullableInt16sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt16sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt16sAttributeSubscriptionState() - } -class NullableInt24sAttribute( - val value: Int? - ) + object SubscriptionEstablished : NullableInt16sAttributeSubscriptionState() + } + + class NullableInt24sAttribute(val value: Int?) sealed class NullableInt24sAttributeSubscriptionState { - data class Success( - val value: Int? - ) : NullableInt24sAttributeSubscriptionState() - + data class Success(val value: Int?) : NullableInt24sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt24sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt24sAttributeSubscriptionState() - } -class NullableInt32sAttribute( - val value: Int? - ) + object SubscriptionEstablished : NullableInt24sAttributeSubscriptionState() + } + + class NullableInt32sAttribute(val value: Int?) sealed class NullableInt32sAttributeSubscriptionState { - data class Success( - val value: Int? - ) : NullableInt32sAttributeSubscriptionState() - + data class Success(val value: Int?) : NullableInt32sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt32sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt32sAttributeSubscriptionState() - } -class NullableInt40sAttribute( - val value: Long? - ) + object SubscriptionEstablished : NullableInt32sAttributeSubscriptionState() + } + + class NullableInt40sAttribute(val value: Long?) sealed class NullableInt40sAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NullableInt40sAttributeSubscriptionState() - + data class Success(val value: Long?) : NullableInt40sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt40sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt40sAttributeSubscriptionState() - } -class NullableInt48sAttribute( - val value: Long? - ) + object SubscriptionEstablished : NullableInt40sAttributeSubscriptionState() + } + + class NullableInt48sAttribute(val value: Long?) sealed class NullableInt48sAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NullableInt48sAttributeSubscriptionState() - + data class Success(val value: Long?) : NullableInt48sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt48sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt48sAttributeSubscriptionState() - } -class NullableInt56sAttribute( - val value: Long? - ) + object SubscriptionEstablished : NullableInt48sAttributeSubscriptionState() + } + + class NullableInt56sAttribute(val value: Long?) sealed class NullableInt56sAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NullableInt56sAttributeSubscriptionState() - + data class Success(val value: Long?) : NullableInt56sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt56sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt56sAttributeSubscriptionState() - } -class NullableInt64sAttribute( - val value: Long? - ) + object SubscriptionEstablished : NullableInt56sAttributeSubscriptionState() + } + + class NullableInt64sAttribute(val value: Long?) sealed class NullableInt64sAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NullableInt64sAttributeSubscriptionState() - + data class Success(val value: Long?) : NullableInt64sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt64sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt64sAttributeSubscriptionState() - } -class NullableEnum8Attribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableInt64sAttributeSubscriptionState() + } + + class NullableEnum8Attribute(val value: UByte?) sealed class NullableEnum8AttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableEnum8AttributeSubscriptionState() - + data class Success(val value: UByte?) : NullableEnum8AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableEnum8AttributeSubscriptionState() - object SubscriptionEstablished : NullableEnum8AttributeSubscriptionState() - } -class NullableEnum16Attribute( - val value: UShort? - ) + object SubscriptionEstablished : NullableEnum8AttributeSubscriptionState() + } + + class NullableEnum16Attribute(val value: UShort?) sealed class NullableEnum16AttributeSubscriptionState { - data class Success( - val value: UShort? - ) : NullableEnum16AttributeSubscriptionState() - + data class Success(val value: UShort?) : NullableEnum16AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableEnum16AttributeSubscriptionState() - object SubscriptionEstablished : NullableEnum16AttributeSubscriptionState() - } -class NullableFloatSingleAttribute( - val value: Float? - ) + object SubscriptionEstablished : NullableEnum16AttributeSubscriptionState() + } + + class NullableFloatSingleAttribute(val value: Float?) sealed class NullableFloatSingleAttributeSubscriptionState { - data class Success( - val value: Float? - ) : NullableFloatSingleAttributeSubscriptionState() - + data class Success(val value: Float?) : NullableFloatSingleAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableFloatSingleAttributeSubscriptionState() - object SubscriptionEstablished : NullableFloatSingleAttributeSubscriptionState() - } -class NullableFloatDoubleAttribute( - val value: Double? - ) + object SubscriptionEstablished : NullableFloatSingleAttributeSubscriptionState() + } + + class NullableFloatDoubleAttribute(val value: Double?) sealed class NullableFloatDoubleAttributeSubscriptionState { - data class Success( - val value: Double? - ) : NullableFloatDoubleAttributeSubscriptionState() - + data class Success(val value: Double?) : NullableFloatDoubleAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableFloatDoubleAttributeSubscriptionState() - object SubscriptionEstablished : NullableFloatDoubleAttributeSubscriptionState() - } -class NullableOctetStringAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : NullableFloatDoubleAttributeSubscriptionState() + } + + class NullableOctetStringAttribute(val value: ByteArray?) sealed class NullableOctetStringAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : NullableOctetStringAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : NullableOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : NullableOctetStringAttributeSubscriptionState() - } -class NullableCharStringAttribute( - val value: String? - ) + object SubscriptionEstablished : NullableOctetStringAttributeSubscriptionState() + } + + class NullableCharStringAttribute(val value: String?) sealed class NullableCharStringAttributeSubscriptionState { - data class Success( - val value: String? - ) : NullableCharStringAttributeSubscriptionState() - + data class Success(val value: String?) : NullableCharStringAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableCharStringAttributeSubscriptionState() - object SubscriptionEstablished : NullableCharStringAttributeSubscriptionState() - } -class NullableEnumAttrAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableCharStringAttributeSubscriptionState() + } + + class NullableEnumAttrAttribute(val value: UByte?) sealed class NullableEnumAttrAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableEnumAttrAttributeSubscriptionState() - + data class Success(val value: UByte?) : NullableEnumAttrAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableEnumAttrAttributeSubscriptionState() - object SubscriptionEstablished : NullableEnumAttrAttributeSubscriptionState() - } -class NullableStructAttribute( - val value: UnitTestingClusterSimpleStruct? - ) + object SubscriptionEstablished : NullableEnumAttrAttributeSubscriptionState() + } + + class NullableStructAttribute(val value: UnitTestingClusterSimpleStruct?) sealed class NullableStructAttributeSubscriptionState { - data class Success( - val value: UnitTestingClusterSimpleStruct? - ) : NullableStructAttributeSubscriptionState() - + data class Success(val value: UnitTestingClusterSimpleStruct?) : + NullableStructAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableStructAttributeSubscriptionState() - object SubscriptionEstablished : NullableStructAttributeSubscriptionState() - } -class NullableRangeRestrictedInt8uAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableStructAttributeSubscriptionState() + } + + class NullableRangeRestrictedInt8uAttribute(val value: UByte?) sealed class NullableRangeRestrictedInt8uAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableRangeRestrictedInt8uAttributeSubscriptionState() - - data class Error(val exception: Exception) : NullableRangeRestrictedInt8uAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt8uAttributeSubscriptionState() - } -class NullableRangeRestrictedInt8sAttribute( - val value: Byte? - ) + data class Success(val value: UByte?) : + NullableRangeRestrictedInt8uAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NullableRangeRestrictedInt8uAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt8uAttributeSubscriptionState() + } + + class NullableRangeRestrictedInt8sAttribute(val value: Byte?) sealed class NullableRangeRestrictedInt8sAttributeSubscriptionState { - data class Success( - val value: Byte? - ) : NullableRangeRestrictedInt8sAttributeSubscriptionState() - - data class Error(val exception: Exception) : NullableRangeRestrictedInt8sAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt8sAttributeSubscriptionState() - } -class NullableRangeRestrictedInt16uAttribute( - val value: UShort? - ) + data class Success(val value: Byte?) : NullableRangeRestrictedInt8sAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NullableRangeRestrictedInt8sAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt8sAttributeSubscriptionState() + } + + class NullableRangeRestrictedInt16uAttribute(val value: UShort?) sealed class NullableRangeRestrictedInt16uAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : NullableRangeRestrictedInt16uAttributeSubscriptionState() - - data class Error(val exception: Exception) : NullableRangeRestrictedInt16uAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt16uAttributeSubscriptionState() - } -class NullableRangeRestrictedInt16sAttribute( - val value: Short? - ) + data class Success(val value: UShort?) : + NullableRangeRestrictedInt16uAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NullableRangeRestrictedInt16uAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt16uAttributeSubscriptionState() + } + + class NullableRangeRestrictedInt16sAttribute(val value: Short?) sealed class NullableRangeRestrictedInt16sAttributeSubscriptionState { - data class Success( - val value: Short? - ) : NullableRangeRestrictedInt16sAttributeSubscriptionState() - - data class Error(val exception: Exception) : NullableRangeRestrictedInt16sAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt16sAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: Short?) : + NullableRangeRestrictedInt16sAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NullableRangeRestrictedInt16sAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt16sAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun test(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -747,7 +601,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -765,7 +619,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -782,39 +636,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getUByte(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } - tlvReader.exitContainer() - return TestSpecificResponse( - returnValue_decoded - ) + return TestSpecificResponse(returnValue_decoded) } suspend fun testUnknownCommand(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -828,9 +674,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun testAddArguments(arg1: UByte - ,arg2: UByte - ,timedInvokeTimeout: Duration? = null): TestAddArgumentsResponse { + suspend fun testAddArguments( + arg1: UByte, + arg2: UByte, + timedInvokeTimeout: Duration? = null + ): TestAddArgumentsResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -840,7 +688,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) val TAG_ARG2_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) tlvWriter.endStructure() val request: InvokeRequest = @@ -857,43 +705,37 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getUByte(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } - tlvReader.exitContainer() - return TestAddArgumentsResponse( - returnValue_decoded - ) + return TestAddArgumentsResponse(returnValue_decoded) } - suspend fun testSimpleArgumentRequest(arg1: Boolean - ,timedInvokeTimeout: Duration? = null): TestSimpleArgumentResponse { + suspend fun testSimpleArgumentRequest( + arg1: Boolean, + timedInvokeTimeout: Duration? = null + ): TestSimpleArgumentResponse { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) tlvWriter.endStructure() val request: InvokeRequest = @@ -910,41 +752,35 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } - tlvReader.exitContainer() - return TestSimpleArgumentResponse( - returnValue_decoded - ) + return TestSimpleArgumentResponse(returnValue_decoded) } - suspend fun testStructArrayArgumentRequest(arg1: List - ,arg2: List - ,arg3: List - ,arg4: List - ,arg5: UByte - ,arg6: Boolean - ,timedInvokeTimeout: Duration? = null): TestStructArrayArgumentResponse { + suspend fun testStructArrayArgumentRequest( + arg1: List, + arg2: List, + arg3: List, + arg4: List, + arg5: UByte, + arg6: Boolean, + timedInvokeTimeout: Duration? = null + ): TestStructArrayArgumentResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -952,37 +788,37 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_ARG2_REQ: Int = 1 tlvWriter.startArray(ContextSpecificTag(TAG_ARG2_REQ)) - for (item in arg2.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg2.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_ARG3_REQ: Int = 2 tlvWriter.startArray(ContextSpecificTag(TAG_ARG3_REQ)) - for (item in arg3.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg3.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val TAG_ARG4_REQ: Int = 3 tlvWriter.startArray(ContextSpecificTag(TAG_ARG4_REQ)) - for (item in arg4.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg4.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val TAG_ARG5_REQ: Int = 4 tlvWriter.put(ContextSpecificTag(TAG_ARG5_REQ), arg5) val TAG_ARG6_REQ: Int = 5 - tlvWriter.put(ContextSpecificTag(TAG_ARG6_REQ), arg6) + tlvWriter.put(ContextSpecificTag(TAG_ARG6_REQ), arg6) tlvWriter.endStructure() val request: InvokeRequest = @@ -999,100 +835,103 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: List? = null - + val TAG_ARG2: Int = 1 var arg2_decoded: List? = null - + val TAG_ARG3: Int = 2 var arg3_decoded: List? = null - + val TAG_ARG4: Int = 3 var arg4_decoded: List? = null - + val TAG_ARG5: Int = 4 var arg5_decoded: UByte? = null - + val TAG_ARG6: Int = 5 var arg6_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }} - - if (tag == ContextSpecificTag(TAG_ARG2)) {arg2_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }} - - if (tag == ContextSpecificTag(TAG_ARG3)) {arg3_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }} - - if (tag == ContextSpecificTag(TAG_ARG4)) {arg4_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getBoolean(AnonymousTag)) - } - tlvReader.exitContainer() - }} - - if (tag == ContextSpecificTag(TAG_ARG5)) {arg5_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_ARG6)) {arg6_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG2)) { + arg2_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG3)) { + arg3_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG4)) { + arg4_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getBoolean(AnonymousTag)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG5)) { + arg5_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_ARG6)) { + arg6_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - - + if (arg2_decoded == null) { - throw IllegalStateException("arg2 not found in TLV") + throw IllegalStateException("arg2 not found in TLV") } - - + if (arg3_decoded == null) { - throw IllegalStateException("arg3 not found in TLV") + throw IllegalStateException("arg3 not found in TLV") } - - + if (arg4_decoded == null) { - throw IllegalStateException("arg4 not found in TLV") + throw IllegalStateException("arg4 not found in TLV") } - - + if (arg5_decoded == null) { - throw IllegalStateException("arg5 not found in TLV") + throw IllegalStateException("arg5 not found in TLV") } - - + if (arg6_decoded == null) { - throw IllegalStateException("arg6 not found in TLV") + throw IllegalStateException("arg6 not found in TLV") } - tlvReader.exitContainer() @@ -1106,15 +945,17 @@ class AttributeListAttribute( ) } - suspend fun testStructArgumentRequest(arg1: UnitTestingClusterSimpleStruct - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testStructArgumentRequest( + arg1: UnitTestingClusterSimpleStruct, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 7u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1131,43 +972,37 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testNestedStructArgumentRequest(arg1: UnitTestingClusterNestedStruct - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testNestedStructArgumentRequest( + arg1: UnitTestingClusterNestedStruct, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1184,36 +1019,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testListStructArgumentRequest(arg1: List - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testListStructArgumentRequest( + arg1: List, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -1221,10 +1050,10 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1241,36 +1070,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testListInt8UArgumentRequest(arg1: List - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testListInt8UArgumentRequest( + arg1: List, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 10u val tlvWriter = TlvWriter() @@ -1278,10 +1101,10 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1298,43 +1121,37 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testNestedStructListArgumentRequest(arg1: UnitTestingClusterNestedStructList - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testNestedStructListArgumentRequest( + arg1: UnitTestingClusterNestedStructList, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1351,36 +1168,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testListNestedStructListArgumentRequest(arg1: List - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testListNestedStructListArgumentRequest( + arg1: List, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 12u val tlvWriter = TlvWriter() @@ -1388,10 +1199,10 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1408,36 +1219,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testListInt8UReverseRequest(arg1: List - ,timedInvokeTimeout: Duration? = null): TestListInt8UReverseResponse { + suspend fun testListInt8UReverseRequest( + arg1: List, + timedInvokeTimeout: Duration? = null + ): TestListInt8UReverseResponse { val commandId: UInt = 13u val tlvWriter = TlvWriter() @@ -1445,10 +1250,10 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1465,43 +1270,38 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }} - - - else { + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - tlvReader.exitContainer() - return TestListInt8UReverseResponse( - arg1_decoded - ) + return TestListInt8UReverseResponse(arg1_decoded) } - suspend fun testEnumsRequest(arg1: UShort - ,arg2: UByte - ,timedInvokeTimeout: Duration? = null): TestEnumsResponse { + suspend fun testEnumsRequest( + arg1: UShort, + arg2: UByte, + timedInvokeTimeout: Duration? = null + ): TestEnumsResponse { val commandId: UInt = 14u val tlvWriter = TlvWriter() @@ -1511,7 +1311,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) val TAG_ARG2_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) tlvWriter.endStructure() val request: InvokeRequest = @@ -1528,56 +1328,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: UShort? = null - + val TAG_ARG2: Int = 1 var arg2_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_ARG2)) {arg2_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = tlvReader.getUShort(tag) + } - else { + if (tag == ContextSpecificTag(TAG_ARG2)) { + arg2_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - - + if (arg2_decoded == null) { - throw IllegalStateException("arg2 not found in TLV") + throw IllegalStateException("arg2 not found in TLV") } - tlvReader.exitContainer() - return TestEnumsResponse( - arg1_decoded, - arg2_decoded - ) + return TestEnumsResponse(arg1_decoded, arg2_decoded) } - suspend fun testNullableOptionalRequest(arg1: UByte? - ,timedInvokeTimeout: Duration? = null): TestNullableOptionalResponse { + suspend fun testNullableOptionalRequest( + arg1: UByte?, + timedInvokeTimeout: Duration? = null + ): TestNullableOptionalResponse { val commandId: UInt = 15u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1?.let { - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) - } + arg1?.let { tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) } tlvWriter.endStructure() val request: InvokeRequest = @@ -1594,82 +1386,76 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_WAS_PRESENT: Int = 0 var wasPresent_decoded: Boolean? = null - + val TAG_WAS_NULL: Int = 1 var wasNull_decoded: Boolean? = null - + val TAG_VALUE: Int = 2 var value_decoded: UByte? = null - + val TAG_ORIGINAL_VALUE: Int = 3 var originalValue_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_WAS_PRESENT)) {wasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_WAS_NULL)) {wasNull_decoded = + if (tag == ContextSpecificTag(TAG_WAS_PRESENT)) { + wasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_WAS_NULL)) { + wasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_ORIGINAL_VALUE)) {originalValue_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_ORIGINAL_VALUE)) { + originalValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (wasPresent_decoded == null) { - throw IllegalStateException("wasPresent not found in TLV") + throw IllegalStateException("wasPresent not found in TLV") } - - - - - - - tlvReader.exitContainer() @@ -1681,33 +1467,31 @@ class AttributeListAttribute( ) } - suspend fun testComplexNullableOptionalRequest(nullableInt: UShort? - ,optionalInt: UShort? - ,nullableOptionalInt: UShort? - ,nullableString: String? - ,optionalString: String? - ,nullableOptionalString: String? - ,nullableStruct: UnitTestingClusterSimpleStruct? - ,optionalStruct: UnitTestingClusterSimpleStruct? - ,nullableOptionalStruct: UnitTestingClusterSimpleStruct? - ,nullableList: List? - ,optionalList: List? - ,nullableOptionalList: List? - ,timedInvokeTimeout: Duration? = null): TestComplexNullableOptionalResponse { + suspend fun testComplexNullableOptionalRequest( + nullableInt: UShort?, + optionalInt: UShort?, + nullableOptionalInt: UShort?, + nullableString: String?, + optionalString: String?, + nullableOptionalString: String?, + nullableStruct: UnitTestingClusterSimpleStruct?, + optionalStruct: UnitTestingClusterSimpleStruct?, + nullableOptionalStruct: UnitTestingClusterSimpleStruct?, + nullableList: List?, + optionalList: List?, + nullableOptionalList: List?, + timedInvokeTimeout: Duration? = null + ): TestComplexNullableOptionalResponse { val commandId: UInt = 16u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NULLABLE_INT_REQ: Int = 0 - nullableInt?.let { - tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_INT_REQ), nullableInt) - } + nullableInt?.let { tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_INT_REQ), nullableInt) } val TAG_OPTIONAL_INT_REQ: Int = 1 - optionalInt?.let { - tlvWriter.put(ContextSpecificTag(TAG_OPTIONAL_INT_REQ), optionalInt) - } + optionalInt?.let { tlvWriter.put(ContextSpecificTag(TAG_OPTIONAL_INT_REQ), optionalInt) } val TAG_NULLABLE_OPTIONAL_INT_REQ: Int = 2 nullableOptionalInt?.let { @@ -1769,7 +1553,7 @@ class AttributeListAttribute( tlvWriter.put(AnonymousTag, item) } tlvWriter.endArray() - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1786,426 +1570,431 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NULLABLE_INT_WAS_NULL: Int = 0 var nullableIntWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_INT_VALUE: Int = 1 var nullableIntValue_decoded: UShort? = null - + val TAG_OPTIONAL_INT_WAS_PRESENT: Int = 2 var optionalIntWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_INT_VALUE: Int = 3 var optionalIntValue_decoded: UShort? = null - + val TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT: Int = 4 var nullableOptionalIntWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_INT_WAS_NULL: Int = 5 var nullableOptionalIntWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_INT_VALUE: Int = 6 var nullableOptionalIntValue_decoded: UShort? = null - + val TAG_NULLABLE_STRING_WAS_NULL: Int = 7 var nullableStringWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_STRING_VALUE: Int = 8 var nullableStringValue_decoded: String? = null - + val TAG_OPTIONAL_STRING_WAS_PRESENT: Int = 9 var optionalStringWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_STRING_VALUE: Int = 10 var optionalStringValue_decoded: String? = null - + val TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT: Int = 11 var nullableOptionalStringWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL: Int = 12 var nullableOptionalStringWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRING_VALUE: Int = 13 var nullableOptionalStringValue_decoded: String? = null - + val TAG_NULLABLE_STRUCT_WAS_NULL: Int = 14 var nullableStructWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_STRUCT_VALUE: Int = 15 var nullableStructValue_decoded: UnitTestingClusterSimpleStruct? = null - + val TAG_OPTIONAL_STRUCT_WAS_PRESENT: Int = 16 var optionalStructWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_STRUCT_VALUE: Int = 17 var optionalStructValue_decoded: UnitTestingClusterSimpleStruct? = null - + val TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT: Int = 18 var nullableOptionalStructWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL: Int = 19 var nullableOptionalStructWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRUCT_VALUE: Int = 20 var nullableOptionalStructValue_decoded: UnitTestingClusterSimpleStruct? = null - + val TAG_NULLABLE_LIST_WAS_NULL: Int = 21 var nullableListWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_LIST_VALUE: Int = 22 var nullableListValue_decoded: List? = null - + val TAG_OPTIONAL_LIST_WAS_PRESENT: Int = 23 var optionalListWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_LIST_VALUE: Int = 24 var optionalListValue_decoded: List? = null - + val TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT: Int = 25 var nullableOptionalListWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL: Int = 26 var nullableOptionalListWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_LIST_VALUE: Int = 27 var nullableOptionalListValue_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NULLABLE_INT_WAS_NULL)) {nullableIntWasNull_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_INT_VALUE)) {nullableIntValue_decoded = + if (tag == ContextSpecificTag(TAG_NULLABLE_INT_WAS_NULL)) { + nullableIntWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_INT_VALUE)) { + nullableIntValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_WAS_PRESENT)) {optionalIntWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_VALUE)) {optionalIntValue_decoded = + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_WAS_PRESENT)) { + optionalIntWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_VALUE)) { + optionalIntValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT)) {nullableOptionalIntWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_NULL)) {nullableOptionalIntWasNull_decoded = + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT)) { + nullableOptionalIntWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_NULL)) { + nullableOptionalIntWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_VALUE)) {nullableOptionalIntValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_VALUE)) { + nullableOptionalIntValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_WAS_NULL)) {nullableStringWasNull_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_VALUE)) {nullableStringValue_decoded = + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_WAS_NULL)) { + nullableStringWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_VALUE)) { + nullableStringValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_WAS_PRESENT)) {optionalStringWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_VALUE)) {optionalStringValue_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_WAS_PRESENT)) { + optionalStringWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_VALUE)) { + optionalStringValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT)) {nullableOptionalStringWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL)) {nullableOptionalStringWasNull_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT)) { + nullableOptionalStringWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL)) { + nullableOptionalStringWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_VALUE)) {nullableOptionalStringValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_VALUE)) { + nullableOptionalStringValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_WAS_NULL)) {nullableStructWasNull_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_VALUE)) {nullableStructValue_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_WAS_NULL)) { + nullableStructWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_VALUE)) { + nullableStructValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_WAS_PRESENT)) {optionalStructWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_VALUE)) {optionalStructValue_decoded = + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_WAS_PRESENT)) { + optionalStructWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_VALUE)) { + optionalStructValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT)) {nullableOptionalStructWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL)) {nullableOptionalStructWasNull_decoded = + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT)) { + nullableOptionalStructWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL)) { + nullableOptionalStructWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_VALUE)) {nullableOptionalStructValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_VALUE)) { + nullableOptionalStructValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_WAS_NULL)) {nullableListWasNull_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_VALUE)) {nullableListValue_decoded = + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_WAS_NULL)) { + nullableListWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_VALUE)) { + nullableListValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_WAS_PRESENT)) {optionalListWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_VALUE)) {optionalListValue_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_WAS_PRESENT)) { + optionalListWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_VALUE)) { + optionalListValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT)) {nullableOptionalListWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL)) {nullableOptionalListWasNull_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT)) { + nullableOptionalListWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL)) { + nullableOptionalListWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_VALUE)) {nullableOptionalListValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_VALUE)) { + nullableOptionalListValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - - else { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (nullableIntWasNull_decoded == null) { - throw IllegalStateException("nullableIntWasNull not found in TLV") + throw IllegalStateException("nullableIntWasNull not found in TLV") } - - - - + if (optionalIntWasPresent_decoded == null) { - throw IllegalStateException("optionalIntWasPresent not found in TLV") + throw IllegalStateException("optionalIntWasPresent not found in TLV") } - - - - + if (nullableOptionalIntWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalIntWasPresent not found in TLV") - } - - - - - - + throw IllegalStateException("nullableOptionalIntWasPresent not found in TLV") + } + if (nullableStringWasNull_decoded == null) { - throw IllegalStateException("nullableStringWasNull not found in TLV") + throw IllegalStateException("nullableStringWasNull not found in TLV") } - - - - + if (optionalStringWasPresent_decoded == null) { - throw IllegalStateException("optionalStringWasPresent not found in TLV") + throw IllegalStateException("optionalStringWasPresent not found in TLV") } - - - - + if (nullableOptionalStringWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalStringWasPresent not found in TLV") - } - - - - - - + throw IllegalStateException("nullableOptionalStringWasPresent not found in TLV") + } + if (nullableStructWasNull_decoded == null) { - throw IllegalStateException("nullableStructWasNull not found in TLV") + throw IllegalStateException("nullableStructWasNull not found in TLV") } - - - - + if (optionalStructWasPresent_decoded == null) { - throw IllegalStateException("optionalStructWasPresent not found in TLV") + throw IllegalStateException("optionalStructWasPresent not found in TLV") } - - - - + if (nullableOptionalStructWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalStructWasPresent not found in TLV") - } - - - - - - + throw IllegalStateException("nullableOptionalStructWasPresent not found in TLV") + } + if (nullableListWasNull_decoded == null) { - throw IllegalStateException("nullableListWasNull not found in TLV") + throw IllegalStateException("nullableListWasNull not found in TLV") } - - - - + if (optionalListWasPresent_decoded == null) { - throw IllegalStateException("optionalListWasPresent not found in TLV") + throw IllegalStateException("optionalListWasPresent not found in TLV") } - - - - + if (nullableOptionalListWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalListWasPresent not found in TLV") + throw IllegalStateException("nullableOptionalListWasPresent not found in TLV") } - - - - - tlvReader.exitContainer() @@ -2241,15 +2030,17 @@ class AttributeListAttribute( ) } - suspend fun simpleStructEchoRequest(arg1: UnitTestingClusterSimpleStruct - ,timedInvokeTimeout: Duration? = null): SimpleStructResponse { + suspend fun simpleStructEchoRequest( + arg1: UnitTestingClusterSimpleStruct, + timedInvokeTimeout: Duration? = null + ): SimpleStructResponse { val commandId: UInt = 17u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -2266,39 +2057,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: UnitTestingClusterSimpleStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - tlvReader.exitContainer() - return SimpleStructResponse( - arg1_decoded - ) + return SimpleStructResponse(arg1_decoded) } suspend fun timedInvokeRequest(timedInvokeTimeout: Duration) { val commandId: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -2312,17 +2095,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun testSimpleOptionalArgumentRequest(arg1: Boolean? - ,timedInvokeTimeout: Duration? = null) { + suspend fun testSimpleOptionalArgumentRequest( + arg1: Boolean?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 19u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1?.let { - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) - } + arg1?.let { tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) } tlvWriter.endStructure() val request: InvokeRequest = @@ -2336,10 +2119,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun testEmitTestEventRequest(arg1: UByte - ,arg2: UByte - ,arg3: Boolean - ,timedInvokeTimeout: Duration? = null): TestEmitTestEventResponse { + suspend fun testEmitTestEventRequest( + arg1: UByte, + arg2: UByte, + arg3: Boolean, + timedInvokeTimeout: Duration? = null + ): TestEmitTestEventResponse { val commandId: UInt = 20u val tlvWriter = TlvWriter() @@ -2352,7 +2137,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) val TAG_ARG3_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_ARG3_REQ), arg3) + tlvWriter.put(ContextSpecificTag(TAG_ARG3_REQ), arg3) tlvWriter.endStructure() val request: InvokeRequest = @@ -2369,43 +2154,37 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: ULong? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getULong(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getULong(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return TestEmitTestEventResponse( - value_decoded - ) + return TestEmitTestEventResponse(value_decoded) } - suspend fun testEmitTestFabricScopedEventRequest(arg1: UByte - ,timedInvokeTimeout: Duration? = null): TestEmitTestFabricScopedEventResponse { + suspend fun testEmitTestFabricScopedEventRequest( + arg1: UByte, + timedInvokeTimeout: Duration? = null + ): TestEmitTestFabricScopedEventResponse { val commandId: UInt = 21u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) tlvWriter.endStructure() val request: InvokeRequest = @@ -2422,51 +2201,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: ULong? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getULong(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getULong(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return TestEmitTestFabricScopedEventResponse( - value_decoded - ) + return TestEmitTestFabricScopedEventResponse(value_decoded) } - suspend fun testBatchHelperRequest(sleepBeforeResponseTimeMs: UShort - ,sizeOfResponseBuffer: UShort - ,fillCharacter: UByte - ,timedInvokeTimeout: Duration? = null): TestBatchHelperResponse { + suspend fun testBatchHelperRequest( + sleepBeforeResponseTimeMs: UShort, + sizeOfResponseBuffer: UShort, + fillCharacter: UByte, + timedInvokeTimeout: Duration? = null + ): TestBatchHelperResponse { val commandId: UInt = 22u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), sleepBeforeResponseTimeMs) + tlvWriter.put( + ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), + sleepBeforeResponseTimeMs + ) val TAG_SIZE_OF_RESPONSE_BUFFER_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_SIZE_OF_RESPONSE_BUFFER_REQ), sizeOfResponseBuffer) val TAG_FILL_CHARACTER_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) + tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) tlvWriter.endStructure() val request: InvokeRequest = @@ -2483,51 +2259,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_BUFFER: Int = 0 var buffer_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_BUFFER)) {buffer_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_BUFFER)) { + buffer_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (buffer_decoded == null) { - throw IllegalStateException("buffer not found in TLV") + throw IllegalStateException("buffer not found in TLV") } - tlvReader.exitContainer() - return TestBatchHelperResponse( - buffer_decoded - ) + return TestBatchHelperResponse(buffer_decoded) } - suspend fun testSecondBatchHelperRequest(sleepBeforeResponseTimeMs: UShort - ,sizeOfResponseBuffer: UShort - ,fillCharacter: UByte - ,timedInvokeTimeout: Duration? = null): TestBatchHelperResponse { + suspend fun testSecondBatchHelperRequest( + sleepBeforeResponseTimeMs: UShort, + sizeOfResponseBuffer: UShort, + fillCharacter: UByte, + timedInvokeTimeout: Duration? = null + ): TestBatchHelperResponse { val commandId: UInt = 23u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), sleepBeforeResponseTimeMs) + tlvWriter.put( + ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), + sleepBeforeResponseTimeMs + ) val TAG_SIZE_OF_RESPONSE_BUFFER_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_SIZE_OF_RESPONSE_BUFFER_REQ), sizeOfResponseBuffer) val TAG_FILL_CHARACTER_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) + tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) tlvWriter.endStructure() val request: InvokeRequest = @@ -2544,43 +2317,37 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_BUFFER: Int = 0 var buffer_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_BUFFER)) {buffer_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_BUFFER)) { + buffer_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (buffer_decoded == null) { - throw IllegalStateException("buffer not found in TLV") + throw IllegalStateException("buffer not found in TLV") } - tlvReader.exitContainer() - return TestBatchHelperResponse( - buffer_decoded - ) + return TestBatchHelperResponse(buffer_decoded) } - suspend fun testDifferentVendorMeiRequest(arg1: UByte - ,timedInvokeTimeout: Duration? = null): TestDifferentVendorMeiResponse { + suspend fun testDifferentVendorMeiRequest( + arg1: UByte, + timedInvokeTimeout: Duration? = null + ): TestDifferentVendorMeiResponse { val commandId: UInt = 4294049962u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) tlvWriter.endStructure() val request: InvokeRequest = @@ -2597,103 +2364,84 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: UByte? = null - + val TAG_EVENT_NUMBER: Int = 1 var eventNumber_decoded: ULong? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_EVENT_NUMBER)) {eventNumber_decoded = tlvReader.getULong(tag)} - + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_EVENT_NUMBER)) { + eventNumber_decoded = tlvReader.getULong(tag) + } else { tlvReader.skipElement() } } - - if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - - + if (eventNumber_decoded == null) { - throw IllegalStateException("eventNumber not found in TLV") + throw IllegalStateException("eventNumber not found in TLV") } - tlvReader.exitContainer() - return TestDifferentVendorMeiResponse( - arg1_decoded, - eventNumber_decoded - ) + return TestDifferentVendorMeiResponse(arg1_decoded, eventNumber_decoded) } -suspend fun readBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Boolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Boolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeBooleanAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeBooleanAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2715,7 +2463,7 @@ suspend fun readBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBooleanAttribute( @@ -2723,35 +2471,37 @@ suspend fun readBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Boolean attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Boolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2763,67 +2513,56 @@ suspend fun readBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBitmap8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBitmap8Attribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap8 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bitmap8 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeBitmap8Attribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2845,7 +2584,7 @@ suspend fun readBitmap8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 1u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap8Attribute( @@ -2853,35 +2592,37 @@ suspend fun readBitmap8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap8 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bitmap8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2893,67 +2634,56 @@ suspend fun readBitmap8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBitmap16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBitmap16Attribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap16 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bitmap16 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeBitmap16Attribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2975,7 +2705,7 @@ suspend fun readBitmap16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 2u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap16Attribute( @@ -2983,35 +2713,37 @@ suspend fun readBitmap16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap16 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bitmap16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3023,67 +2755,56 @@ suspend fun readBitmap16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 2u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBitmap32Attribute(): UInt {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBitmap32Attribute(): UInt { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap32 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bitmap32 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } - suspend fun writeBitmap32Attribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap32Attribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3105,7 +2826,7 @@ suspend fun readBitmap32Attribute(): UInt {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap32Attribute( @@ -3113,35 +2834,37 @@ suspend fun readBitmap32Attribute(): UInt {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap32 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bitmap32 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3153,67 +2876,56 @@ suspend fun readBitmap32Attribute(): UInt {val ATTRIBUTE_ID: UInt = 3u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBitmap64Attribute(): ULong {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBitmap64Attribute(): ULong { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap64 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bitmap64 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeBitmap64Attribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap64Attribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3235,7 +2947,7 @@ suspend fun readBitmap64Attribute(): ULong {val ATTRIBUTE_ID: UInt = 4u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap64Attribute( @@ -3243,35 +2955,37 @@ suspend fun readBitmap64Attribute(): ULong {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap64 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bitmap64 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3283,67 +2997,56 @@ suspend fun readBitmap64Attribute(): ULong {val ATTRIBUTE_ID: UInt = 4u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt8uAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeInt8uAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3365,7 +3068,7 @@ suspend fun readInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt8uAttribute( @@ -3373,35 +3076,37 @@ suspend fun readInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int8u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3413,67 +3118,56 @@ suspend fun readInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt16uAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int16u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int16u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeInt16uAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt16uAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3495,7 +3189,7 @@ suspend fun readInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt16uAttribute( @@ -3503,35 +3197,37 @@ suspend fun readInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int16u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3543,67 +3239,56 @@ suspend fun readInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt24uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt24uAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int24u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int24u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } - suspend fun writeInt24uAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt24uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3625,7 +3310,7 @@ suspend fun readInt24uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 7u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt24uAttribute( @@ -3633,35 +3318,37 @@ suspend fun readInt24uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int24u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int24u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3673,67 +3360,56 @@ suspend fun readInt24uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 7u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt32uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt32uAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int32u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int32u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } - suspend fun writeInt32uAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt32uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3755,7 +3431,7 @@ suspend fun readInt32uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 8u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt32uAttribute( @@ -3763,35 +3439,37 @@ suspend fun readInt32uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int32u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int32u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3803,67 +3481,56 @@ suspend fun readInt32uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 8u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt40uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt40uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int40u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int40u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeInt40uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt40uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3885,7 +3552,7 @@ suspend fun readInt40uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 9u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt40uAttribute( @@ -3893,35 +3560,37 @@ suspend fun readInt40uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int40u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int40u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3933,67 +3602,56 @@ suspend fun readInt40uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 9u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt48uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt48uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int48u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int48u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeInt48uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt48uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4015,7 +3673,7 @@ suspend fun readInt48uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 10u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt48uAttribute( @@ -4023,35 +3681,37 @@ suspend fun readInt48uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int48u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int48u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4063,67 +3723,56 @@ suspend fun readInt48uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 10u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt56uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt56uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int56u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int56u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeInt56uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt56uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 11u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4145,7 +3794,7 @@ suspend fun readInt56uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 11u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt56uAttribute( @@ -4153,35 +3802,37 @@ suspend fun readInt56uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 11u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int56u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int56u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4193,67 +3844,56 @@ suspend fun readInt56uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 11u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt64uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt64uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int64u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int64u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeInt64uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt64uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 12u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4275,7 +3915,7 @@ suspend fun readInt64uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 12u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt64uAttribute( @@ -4283,35 +3923,37 @@ suspend fun readInt64uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 12u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int64u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int64u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4323,67 +3965,56 @@ suspend fun readInt64uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 12u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt8sAttribute(): Byte { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int8s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int8s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Byte = tlvReader.getByte(AnonymousTag) - return decodedValue } - suspend fun writeInt8sAttribute( - value: Byte, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt8sAttribute(value: Byte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 13u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4405,7 +4036,7 @@ suspend fun readInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 13u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt8sAttribute( @@ -4413,35 +4044,37 @@ suspend fun readInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 13u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int8s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4453,67 +4086,56 @@ suspend fun readInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 13u emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt16sAttribute(): Short { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int16s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int16s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Short = tlvReader.getShort(AnonymousTag) - return decodedValue } - suspend fun writeInt16sAttribute( - value: Short, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt16sAttribute(value: Short, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 14u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4535,7 +4157,7 @@ suspend fun readInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 14u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt16sAttribute( @@ -4543,35 +4165,37 @@ suspend fun readInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 14u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int16s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4583,67 +4207,56 @@ suspend fun readInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 14u emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt24sAttribute(): Int {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt24sAttribute(): Int { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int24s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int24s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Int = tlvReader.getInt(AnonymousTag) - return decodedValue } - suspend fun writeInt24sAttribute( - value: Int, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt24sAttribute(value: Int, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 15u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4665,7 +4278,7 @@ suspend fun readInt24sAttribute(): Int {val ATTRIBUTE_ID: UInt = 15u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt24sAttribute( @@ -4673,35 +4286,37 @@ suspend fun readInt24sAttribute(): Int {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int24s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int24s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4713,67 +4328,56 @@ suspend fun readInt24sAttribute(): Int {val ATTRIBUTE_ID: UInt = 15u emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt32sAttribute(): Int {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt32sAttribute(): Int { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int32s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int32s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Int = tlvReader.getInt(AnonymousTag) - return decodedValue } - suspend fun writeInt32sAttribute( - value: Int, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt32sAttribute(value: Int, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4795,7 +4399,7 @@ suspend fun readInt32sAttribute(): Int {val ATTRIBUTE_ID: UInt = 16u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt32sAttribute( @@ -4803,35 +4407,37 @@ suspend fun readInt32sAttribute(): Int {val ATTRIBUTE_ID: UInt = 16u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int32s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int32s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4843,67 +4449,56 @@ suspend fun readInt32sAttribute(): Int {val ATTRIBUTE_ID: UInt = 16u emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt40sAttribute(): Long {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt40sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int40s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int40s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } - suspend fun writeInt40sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt40sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4925,7 +4520,7 @@ suspend fun readInt40sAttribute(): Long {val ATTRIBUTE_ID: UInt = 17u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt40sAttribute( @@ -4933,35 +4528,37 @@ suspend fun readInt40sAttribute(): Long {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int40s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int40s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4973,67 +4570,56 @@ suspend fun readInt40sAttribute(): Long {val ATTRIBUTE_ID: UInt = 17u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt48sAttribute(): Long {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt48sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int48s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int48s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } - suspend fun writeInt48sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt48sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5055,7 +4641,7 @@ suspend fun readInt48sAttribute(): Long {val ATTRIBUTE_ID: UInt = 18u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt48sAttribute( @@ -5063,35 +4649,37 @@ suspend fun readInt48sAttribute(): Long {val ATTRIBUTE_ID: UInt = 18u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int48s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int48s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5103,67 +4691,56 @@ suspend fun readInt48sAttribute(): Long {val ATTRIBUTE_ID: UInt = 18u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt56sAttribute(): Long {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt56sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int56s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int56s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } - suspend fun writeInt56sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt56sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 19u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5185,7 +4762,7 @@ suspend fun readInt56sAttribute(): Long {val ATTRIBUTE_ID: UInt = 19u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt56sAttribute( @@ -5193,35 +4770,37 @@ suspend fun readInt56sAttribute(): Long {val ATTRIBUTE_ID: UInt = 19u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int56s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int56s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5233,67 +4812,56 @@ suspend fun readInt56sAttribute(): Long {val ATTRIBUTE_ID: UInt = 19u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt64sAttribute(): Long {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt64sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int64s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int64s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } - suspend fun writeInt64sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt64sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5315,7 +4883,7 @@ suspend fun readInt64sAttribute(): Long {val ATTRIBUTE_ID: UInt = 20u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt64sAttribute( @@ -5323,35 +4891,37 @@ suspend fun readInt64sAttribute(): Long {val ATTRIBUTE_ID: UInt = 20u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int64s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int64s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5363,67 +4933,56 @@ suspend fun readInt64sAttribute(): Long {val ATTRIBUTE_ID: UInt = 20u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnum8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnum8Attribute(): UByte { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enum8 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enum8 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeEnum8Attribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeEnum8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5445,7 +5004,7 @@ suspend fun readEnum8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 21u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnum8Attribute( @@ -5453,35 +5012,37 @@ suspend fun readEnum8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 21u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enum8 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Enum8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5493,67 +5054,56 @@ suspend fun readEnum8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 21u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnum16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnum16Attribute(): UShort { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enum16 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enum16 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeEnum16Attribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeEnum16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 22u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5575,7 +5125,7 @@ suspend fun readEnum16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 22u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnum16Attribute( @@ -5583,35 +5133,37 @@ suspend fun readEnum16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 22u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enum16 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Enum16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5623,67 +5175,56 @@ suspend fun readEnum16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 22u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFloatSingleAttribute(): Float {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFloatSingleAttribute(): Float { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Floatsingle attribute not found in response" - } + } + + requireNotNull(attributeData) { "Floatsingle attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Float = tlvReader.getFloat(AnonymousTag) - return decodedValue } - suspend fun writeFloatSingleAttribute( - value: Float, - timedWriteTimeout: Duration? = null) { + suspend fun writeFloatSingleAttribute(value: Float, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5705,7 +5246,7 @@ suspend fun readFloatSingleAttribute(): Float {val ATTRIBUTE_ID: UInt = 23u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFloatSingleAttribute( @@ -5713,35 +5254,37 @@ suspend fun readFloatSingleAttribute(): Float {val ATTRIBUTE_ID: UInt = 23u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Floatsingle attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Floatsingle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5753,67 +5296,56 @@ suspend fun readFloatSingleAttribute(): Float {val ATTRIBUTE_ID: UInt = 23u emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFloatDoubleAttribute(): Double {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFloatDoubleAttribute(): Double { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Floatdouble attribute not found in response" - } + } + + requireNotNull(attributeData) { "Floatdouble attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Double = tlvReader.getDouble(AnonymousTag) - return decodedValue } - suspend fun writeFloatDoubleAttribute( - value: Double, - timedWriteTimeout: Duration? = null) { + suspend fun writeFloatDoubleAttribute(value: Double, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 24u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5835,7 +5367,7 @@ suspend fun readFloatDoubleAttribute(): Double {val ATTRIBUTE_ID: UInt = 24u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFloatDoubleAttribute( @@ -5843,35 +5375,37 @@ suspend fun readFloatDoubleAttribute(): Double {val ATTRIBUTE_ID: UInt = 24u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DoubleSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DoubleSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Floatdouble attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Floatdouble attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5883,67 +5417,56 @@ suspend fun readFloatDoubleAttribute(): Double {val ATTRIBUTE_ID: UInt = 24u emit(DoubleSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOctetStringAttribute(): ByteArray { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Octetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Octetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ByteArray = tlvReader.getByteArray(AnonymousTag) - return decodedValue } - suspend fun writeOctetStringAttribute( - value: ByteArray, - timedWriteTimeout: Duration? = null) { + suspend fun writeOctetStringAttribute(value: ByteArray, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 25u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5965,7 +5488,7 @@ suspend fun readOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 25u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOctetStringAttribute( @@ -5973,35 +5496,37 @@ suspend fun readOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 25u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteArraySubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Octetstring attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Octetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6013,77 +5538,67 @@ suspend fun readOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 25u emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListInt8uAttribute(): ListInt8uAttribute {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListInt8uAttribute(): ListInt8uAttribute { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Listint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListInt8uAttribute(decodedValue) } - suspend fun writeListInt8uAttribute( - value: List, - timedWriteTimeout: Duration? = null) { + suspend fun writeListInt8uAttribute(value: List, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 26u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6105,7 +5620,7 @@ suspend fun readListInt8uAttribute(): ListInt8uAttribute {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListInt8uAttribute( @@ -6113,45 +5628,48 @@ suspend fun readListInt8uAttribute(): ListInt8uAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListInt8uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListInt8uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listint8u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Listint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ListInt8uAttributeSubscriptionState.Success(decodedValue)) } @@ -6159,77 +5677,70 @@ suspend fun readListInt8uAttribute(): ListInt8uAttribute {val ATTRIBUTE_ID: UInt emit(ListInt8uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListOctetStringAttribute(): ListOctetStringAttribute {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListOctetStringAttribute(): ListOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Listoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListOctetStringAttribute(decodedValue) } suspend fun writeListOctetStringAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 27u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6251,7 +5762,7 @@ suspend fun readListOctetStringAttribute(): ListOctetStringAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListOctetStringAttribute( @@ -6259,45 +5770,50 @@ suspend fun readListOctetStringAttribute(): ListOctetStringAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListOctetStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Listoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ListOctetStringAttributeSubscriptionState.Success(decodedValue)) } @@ -6305,77 +5821,70 @@ suspend fun readListOctetStringAttribute(): ListOctetStringAttribute {val ATTRIB emit(ListOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Liststructoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Liststructoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListStructOctetStringAttribute(decodedValue) } suspend fun writeListStructOctetStringAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 28u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6397,7 +5906,7 @@ suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListStructOctetStringAttribute( @@ -6405,45 +5914,50 @@ suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListStructOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListStructOctetStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Liststructoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Liststructoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ListStructOctetStringAttributeSubscriptionState.Success(decodedValue)) } @@ -6451,67 +5965,56 @@ suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute emit(ListStructOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLongOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 29u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLongOctetStringAttribute(): ByteArray { + val ATTRIBUTE_ID: UInt = 29u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Longoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Longoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ByteArray = tlvReader.getByteArray(AnonymousTag) - return decodedValue } - suspend fun writeLongOctetStringAttribute( - value: ByteArray, - timedWriteTimeout: Duration? = null) { + suspend fun writeLongOctetStringAttribute(value: ByteArray, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 29u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6533,7 +6036,7 @@ suspend fun readLongOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLongOctetStringAttribute( @@ -6541,34 +6044,38 @@ suspend fun readLongOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 29u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteArraySubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Longoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Longoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6581,67 +6088,56 @@ suspend fun readLongOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 30u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCharStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Charstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Charstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeCharStringAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeCharStringAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 30u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6663,7 +6159,7 @@ suspend fun readCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 30u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCharStringAttribute( @@ -6671,35 +6167,37 @@ suspend fun readCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 30u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Charstring attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Charstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6711,67 +6209,56 @@ suspend fun readCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 30u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLongCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 31u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLongCharStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 31u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Longcharstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Longcharstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeLongCharStringAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLongCharStringAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 31u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6793,7 +6280,7 @@ suspend fun readLongCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 31u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLongCharStringAttribute( @@ -6801,34 +6288,38 @@ suspend fun readLongCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 31u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 31u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Longcharstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Longcharstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6841,67 +6332,56 @@ suspend fun readLongCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 31u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEpochUsAttribute(): ULong {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEpochUsAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Epochus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Epochus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeEpochUsAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeEpochUsAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 32u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6923,7 +6403,7 @@ suspend fun readEpochUsAttribute(): ULong {val ATTRIBUTE_ID: UInt = 32u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEpochUsAttribute( @@ -6931,35 +6411,37 @@ suspend fun readEpochUsAttribute(): ULong {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Epochus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Epochus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6971,67 +6453,56 @@ suspend fun readEpochUsAttribute(): ULong {val ATTRIBUTE_ID: UInt = 32u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEpochSAttribute(): UInt {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEpochSAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Epochs attribute not found in response" - } + } + + requireNotNull(attributeData) { "Epochs attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } - suspend fun writeEpochSAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeEpochSAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7053,7 +6524,7 @@ suspend fun readEpochSAttribute(): UInt {val ATTRIBUTE_ID: UInt = 33u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEpochSAttribute( @@ -7061,35 +6532,37 @@ suspend fun readEpochSAttribute(): UInt {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Epochs attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Epochs attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7101,67 +6574,56 @@ suspend fun readEpochSAttribute(): UInt {val ATTRIBUTE_ID: UInt = 33u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorIdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVendorIdAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeVendorIdAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeVendorIdAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 34u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7183,7 +6645,7 @@ suspend fun readVendorIdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 34u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeVendorIdAttribute( @@ -7191,35 +6653,37 @@ suspend fun readVendorIdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 34u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7231,77 +6695,73 @@ suspend fun readVendorIdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 34u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListNullablesAndOptionalsStructAttribute(): ListNullablesAndOptionalsStructAttribute {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListNullablesAndOptionalsStructAttribute(): + ListNullablesAndOptionalsStructAttribute { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listnullablesandoptionalsstruct attribute not found in response" + } + + requireNotNull(attributeData) { + "Listnullablesandoptionalsstruct attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListNullablesAndOptionalsStructAttribute(decodedValue) } suspend fun writeListNullablesAndOptionalsStructAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 35u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7323,7 +6783,7 @@ suspend fun readListNullablesAndOptionalsStructAttribute(): ListNullablesAndOpti throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListNullablesAndOptionalsStructAttribute( @@ -7331,45 +6791,50 @@ suspend fun readListNullablesAndOptionalsStructAttribute(): ListNullablesAndOpti maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListNullablesAndOptionalsStructAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListNullablesAndOptionalsStructAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listnullablesandoptionalsstruct attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Listnullablesandoptionalsstruct attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ListNullablesAndOptionalsStructAttributeSubscriptionState.Success(decodedValue)) } @@ -7377,67 +6842,56 @@ suspend fun readListNullablesAndOptionalsStructAttribute(): ListNullablesAndOpti emit(ListNullablesAndOptionalsStructAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnumAttrAttribute(): UByte {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnumAttrAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enumattr attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enumattr attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeEnumAttrAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeEnumAttrAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 36u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7459,7 +6913,7 @@ suspend fun readEnumAttrAttribute(): UByte {val ATTRIBUTE_ID: UInt = 36u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnumAttrAttribute( @@ -7467,35 +6921,37 @@ suspend fun readEnumAttrAttribute(): UByte {val ATTRIBUTE_ID: UInt = 36u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enumattr attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Enumattr attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7507,67 +6963,60 @@ suspend fun readEnumAttrAttribute(): UByte {val ATTRIBUTE_ID: UInt = 36u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStructAttrAttribute(): StructAttrAttribute {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStructAttrAttribute(): StructAttrAttribute { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Structattr attribute not found in response" - } + } + + requireNotNull(attributeData) { "Structattr attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct = UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: UnitTestingClusterSimpleStruct = + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) return StructAttrAttribute(decodedValue) } suspend fun writeStructAttrAttribute( value: UnitTestingClusterSimpleStruct, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 37u val tlvWriter = TlvWriter() - value.toTlv(AnonymousTag, tlvWriter) + value.toTlv(AnonymousTag, tlvWriter) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7589,7 +7038,7 @@ suspend fun readStructAttrAttribute(): StructAttrAttribute {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStructAttrAttribute( @@ -7597,39 +7046,42 @@ suspend fun readStructAttrAttribute(): StructAttrAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StructAttrAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StructAttrAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Structattr attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Structattr attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct = UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: UnitTestingClusterSimpleStruct = + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) emit(StructAttrAttributeSubscriptionState.Success(decodedValue)) } @@ -7637,67 +7089,59 @@ suspend fun readStructAttrAttribute(): StructAttrAttribute {val ATTRIBUTE_ID: UI emit(StructAttrAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRangeRestrictedInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRangeRestrictedInt8uAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rangerestrictedint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } suspend fun writeRangeRestrictedInt8uAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 38u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7719,7 +7163,7 @@ suspend fun readRangeRestrictedInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt8uAttribute( @@ -7727,34 +7171,38 @@ suspend fun readRangeRestrictedInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint8u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rangerestrictedint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7767,67 +7215,56 @@ suspend fun readRangeRestrictedInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRangeRestrictedInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 39u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRangeRestrictedInt8sAttribute(): Byte { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint8s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rangerestrictedint8s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Byte = tlvReader.getByte(AnonymousTag) - return decodedValue } - suspend fun writeRangeRestrictedInt8sAttribute( - value: Byte, - timedWriteTimeout: Duration? = null) { + suspend fun writeRangeRestrictedInt8sAttribute(value: Byte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 39u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7849,7 +7286,7 @@ suspend fun readRangeRestrictedInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt8sAttribute( @@ -7857,34 +7294,38 @@ suspend fun readRangeRestrictedInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint8s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rangerestrictedint8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7897,67 +7338,59 @@ suspend fun readRangeRestrictedInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRangeRestrictedInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 40u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRangeRestrictedInt16uAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint16u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rangerestrictedint16u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } suspend fun writeRangeRestrictedInt16uAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 40u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7979,7 +7412,7 @@ suspend fun readRangeRestrictedInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt16uAttribute( @@ -7987,34 +7420,38 @@ suspend fun readRangeRestrictedInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint16u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rangerestrictedint16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8027,67 +7464,59 @@ suspend fun readRangeRestrictedInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRangeRestrictedInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRangeRestrictedInt16sAttribute(): Short { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint16s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rangerestrictedint16s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Short = tlvReader.getShort(AnonymousTag) - return decodedValue } suspend fun writeRangeRestrictedInt16sAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 41u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8109,7 +7538,7 @@ suspend fun readRangeRestrictedInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt16sAttribute( @@ -8117,34 +7546,38 @@ suspend fun readRangeRestrictedInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint16s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rangerestrictedint16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8157,77 +7590,70 @@ suspend fun readRangeRestrictedInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute {val ATTRIBUTE_ID: UInt = 42u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listlongoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Listlongoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListLongOctetStringAttribute(decodedValue) } suspend fun writeListLongOctetStringAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 42u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8249,7 +7675,7 @@ suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListLongOctetStringAttribute( @@ -8257,45 +7683,50 @@ suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListLongOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListLongOctetStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listlongoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Listlongoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ListLongOctetStringAttributeSubscriptionState.Success(decodedValue)) } @@ -8303,77 +7734,70 @@ suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute {va emit(ListLongOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute {val ATTRIBUTE_ID: UInt = 43u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute { + val ATTRIBUTE_ID: UInt = 43u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listfabricscoped attribute not found in response" - } + } + + requireNotNull(attributeData) { "Listfabricscoped attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListFabricScopedAttribute(decodedValue) } suspend fun writeListFabricScopedAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 43u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8395,7 +7819,7 @@ suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListFabricScopedAttribute( @@ -8403,45 +7827,50 @@ suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 43u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListFabricScopedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListFabricScopedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listfabricscoped attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Listfabricscoped attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ListFabricScopedAttributeSubscriptionState.Success(decodedValue)) } @@ -8449,67 +7878,56 @@ suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute {val ATTR emit(ListFabricScopedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimedWriteBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTimedWriteBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timedwriteboolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timedwriteboolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeTimedWriteBooleanAttribute( - value: Boolean, - timedWriteTimeout: Duration) { + suspend fun writeTimedWriteBooleanAttribute(value: Boolean, timedWriteTimeout: Duration) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8531,7 +7949,7 @@ suspend fun readTimedWriteBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTimedWriteBooleanAttribute( @@ -8539,34 +7957,38 @@ suspend fun readTimedWriteBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timedwriteboolean attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Timedwriteboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8579,67 +8001,59 @@ suspend fun readTimedWriteBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneralErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneralErrorBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generalerrorboolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generalerrorboolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } suspend fun writeGeneralErrorBooleanAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8661,7 +8075,7 @@ suspend fun readGeneralErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeGeneralErrorBooleanAttribute( @@ -8669,34 +8083,38 @@ suspend fun readGeneralErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generalerrorboolean attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generalerrorboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8709,67 +8127,59 @@ suspend fun readGeneralErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterErrorBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clustererrorboolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clustererrorboolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } suspend fun writeClusterErrorBooleanAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8791,7 +8201,7 @@ suspend fun readClusterErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeClusterErrorBooleanAttribute( @@ -8799,34 +8209,38 @@ suspend fun readClusterErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clustererrorboolean attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clustererrorboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8839,71 +8253,61 @@ suspend fun readClusterErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnsupportedAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 255u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnsupportedAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 255u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unsupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unsupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeUnsupportedAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeUnsupportedAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 255u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8925,7 +8329,7 @@ suspend fun readUnsupportedAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 255u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnsupportedAttribute( @@ -8933,119 +8337,109 @@ suspend fun readUnsupportedAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 255u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 255u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unsupported attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Unsupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute {val ATTRIBUTE_ID: UInt = 16384u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableboolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableboolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - tlvReader.getBoolean(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBooleanAttribute(decodedValue) } - suspend fun writeNullableBooleanAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBooleanAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16384u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9067,7 +8461,7 @@ suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBooleanAttribute( @@ -9075,120 +8469,112 @@ suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBooleanAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBooleanAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableboolean attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - tlvReader.getBoolean(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBooleanAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBooleanAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBooleanAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute {val ATTRIBUTE_ID: UInt = 16385u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute { + val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap8 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablebitmap8 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBitmap8Attribute(decodedValue) } - suspend fun writeNullableBitmap8Attribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16385u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9210,7 +8596,7 @@ suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap8Attribute( @@ -9218,120 +8604,112 @@ suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16385u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBitmap8AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBitmap8AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap8 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBitmap8AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBitmap8AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap8AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute {val ATTRIBUTE_ID: UInt = 16386u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute { + val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap16 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablebitmap16 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBitmap16Attribute(decodedValue) } - suspend fun writeNullableBitmap16Attribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16386u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9353,7 +8731,7 @@ suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap16Attribute( @@ -9361,120 +8739,112 @@ suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16386u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBitmap16AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBitmap16AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap16 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBitmap16AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBitmap16AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap16AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute {val ATTRIBUTE_ID: UInt = 16387u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap32 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablebitmap32 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBitmap32Attribute(decodedValue) } - suspend fun writeNullableBitmap32Attribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap32Attribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16387u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9496,7 +8866,7 @@ suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap32Attribute( @@ -9504,120 +8874,112 @@ suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16387u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBitmap32AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBitmap32AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap32 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap32 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBitmap32AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBitmap32AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap32AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute {val ATTRIBUTE_ID: UInt = 16388u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute { + val ATTRIBUTE_ID: UInt = 16388u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap64 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablebitmap64 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBitmap64Attribute(decodedValue) } - suspend fun writeNullableBitmap64Attribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap64Attribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16388u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9639,7 +9001,7 @@ suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap64Attribute( @@ -9647,120 +9009,112 @@ suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16388u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBitmap64AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBitmap64AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap64 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap64 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBitmap64AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBitmap64AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap64AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute {val ATTRIBUTE_ID: UInt = 16389u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute { + val ATTRIBUTE_ID: UInt = 16389u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt8uAttribute(decodedValue) } - suspend fun writeNullableInt8uAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16389u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9782,7 +9136,7 @@ suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt8uAttribute( @@ -9790,120 +9144,110 @@ suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16389u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt8uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt8uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint8u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nullableint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt8uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt8uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt8uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute {val ATTRIBUTE_ID: UInt = 16390u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute { + val ATTRIBUTE_ID: UInt = 16390u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint16u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint16u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt16uAttribute(decodedValue) } - suspend fun writeNullableInt16uAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt16uAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16390u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9925,7 +9269,7 @@ suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt16uAttribute( @@ -9933,120 +9277,112 @@ suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16390u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt16uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt16uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint16u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt16uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt16uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt16uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute {val ATTRIBUTE_ID: UInt = 16391u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute { + val ATTRIBUTE_ID: UInt = 16391u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint24u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint24u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt24uAttribute(decodedValue) } - suspend fun writeNullableInt24uAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt24uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16391u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10068,7 +9404,7 @@ suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt24uAttribute( @@ -10076,120 +9412,112 @@ suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16391u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt24uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt24uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint24u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint24u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt24uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt24uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt24uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute {val ATTRIBUTE_ID: UInt = 16392u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute { + val ATTRIBUTE_ID: UInt = 16392u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint32u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint32u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt32uAttribute(decodedValue) } - suspend fun writeNullableInt32uAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt32uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16392u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10211,7 +9539,7 @@ suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt32uAttribute( @@ -10219,120 +9547,112 @@ suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16392u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt32uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt32uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint32u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint32u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt32uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt32uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt32uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute {val ATTRIBUTE_ID: UInt = 16393u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute { + val ATTRIBUTE_ID: UInt = 16393u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint40u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint40u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt40uAttribute(decodedValue) } - suspend fun writeNullableInt40uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt40uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16393u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10354,7 +9674,7 @@ suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt40uAttribute( @@ -10362,120 +9682,112 @@ suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16393u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt40uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt40uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint40u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint40u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt40uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt40uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt40uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute {val ATTRIBUTE_ID: UInt = 16394u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute { + val ATTRIBUTE_ID: UInt = 16394u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint48u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint48u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt48uAttribute(decodedValue) } - suspend fun writeNullableInt48uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt48uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16394u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10497,7 +9809,7 @@ suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt48uAttribute( @@ -10505,120 +9817,112 @@ suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16394u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt48uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt48uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint48u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint48u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt48uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt48uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt48uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute {val ATTRIBUTE_ID: UInt = 16395u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute { + val ATTRIBUTE_ID: UInt = 16395u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint56u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint56u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt56uAttribute(decodedValue) } - suspend fun writeNullableInt56uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt56uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16395u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10640,7 +9944,7 @@ suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt56uAttribute( @@ -10648,120 +9952,112 @@ suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16395u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt56uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt56uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint56u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint56u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt56uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt56uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt56uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute {val ATTRIBUTE_ID: UInt = 16396u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute { + val ATTRIBUTE_ID: UInt = 16396u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint64u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint64u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt64uAttribute(decodedValue) } - suspend fun writeNullableInt64uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt64uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16396u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10783,7 +10079,7 @@ suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt64uAttribute( @@ -10791,120 +10087,112 @@ suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16396u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt64uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt64uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint64u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint64u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt64uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt64uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt64uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute {val ATTRIBUTE_ID: UInt = 16397u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute { + val ATTRIBUTE_ID: UInt = 16397u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint8s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint8s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt8sAttribute(decodedValue) } - suspend fun writeNullableInt8sAttribute( - value: Byte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt8sAttribute(value: Byte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16397u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10926,7 +10214,7 @@ suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt8sAttribute( @@ -10934,120 +10222,110 @@ suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16397u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt8sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt8sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint8s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nullableint8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt8sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt8sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt8sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute {val ATTRIBUTE_ID: UInt = 16398u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute { + val ATTRIBUTE_ID: UInt = 16398u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint16s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint16s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt16sAttribute(decodedValue) } - suspend fun writeNullableInt16sAttribute( - value: Short, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt16sAttribute(value: Short, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16398u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11069,7 +10347,7 @@ suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt16sAttribute( @@ -11077,120 +10355,112 @@ suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16398u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt16sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt16sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint16s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt16sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt16sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt16sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute {val ATTRIBUTE_ID: UInt = 16399u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute { + val ATTRIBUTE_ID: UInt = 16399u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint24s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint24s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt24sAttribute(decodedValue) } - suspend fun writeNullableInt24sAttribute( - value: Int, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt24sAttribute(value: Int, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16399u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11212,7 +10482,7 @@ suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt24sAttribute( @@ -11220,120 +10490,112 @@ suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16399u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt24sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt24sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint24s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint24s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt24sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt24sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt24sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute {val ATTRIBUTE_ID: UInt = 16400u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute { + val ATTRIBUTE_ID: UInt = 16400u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint32s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint32s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt32sAttribute(decodedValue) } - suspend fun writeNullableInt32sAttribute( - value: Int, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt32sAttribute(value: Int, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16400u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11355,7 +10617,7 @@ suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt32sAttribute( @@ -11363,120 +10625,112 @@ suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16400u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt32sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt32sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint32s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint32s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt32sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt32sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt32sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute {val ATTRIBUTE_ID: UInt = 16401u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute { + val ATTRIBUTE_ID: UInt = 16401u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint40s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint40s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt40sAttribute(decodedValue) } - suspend fun writeNullableInt40sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt40sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16401u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11498,7 +10752,7 @@ suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt40sAttribute( @@ -11506,120 +10760,112 @@ suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16401u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt40sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt40sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint40s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint40s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt40sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt40sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt40sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute {val ATTRIBUTE_ID: UInt = 16402u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute { + val ATTRIBUTE_ID: UInt = 16402u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint48s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint48s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt48sAttribute(decodedValue) } - suspend fun writeNullableInt48sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt48sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16402u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11641,7 +10887,7 @@ suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt48sAttribute( @@ -11649,120 +10895,112 @@ suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16402u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt48sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt48sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint48s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint48s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt48sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt48sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt48sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute {val ATTRIBUTE_ID: UInt = 16403u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute { + val ATTRIBUTE_ID: UInt = 16403u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint56s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint56s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt56sAttribute(decodedValue) } - suspend fun writeNullableInt56sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt56sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16403u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11784,7 +11022,7 @@ suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt56sAttribute( @@ -11792,120 +11030,112 @@ suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16403u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt56sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt56sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint56s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint56s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt56sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt56sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt56sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute {val ATTRIBUTE_ID: UInt = 16404u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute { + val ATTRIBUTE_ID: UInt = 16404u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint64s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint64s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt64sAttribute(decodedValue) } - suspend fun writeNullableInt64sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt64sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16404u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11927,7 +11157,7 @@ suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt64sAttribute( @@ -11935,120 +11165,112 @@ suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16404u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt64sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt64sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint64s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint64s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt64sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt64sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt64sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute {val ATTRIBUTE_ID: UInt = 16405u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute { + val ATTRIBUTE_ID: UInt = 16405u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenum8 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableenum8 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableEnum8Attribute(decodedValue) } - suspend fun writeNullableEnum8Attribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableEnum8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16405u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12070,7 +11292,7 @@ suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableEnum8Attribute( @@ -12078,120 +11300,110 @@ suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16405u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableEnum8AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableEnum8AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenum8 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nullableenum8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableEnum8AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableEnum8AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableEnum8AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute {val ATTRIBUTE_ID: UInt = 16406u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute { + val ATTRIBUTE_ID: UInt = 16406u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenum16 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableenum16 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableEnum16Attribute(decodedValue) } - suspend fun writeNullableEnum16Attribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableEnum16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16406u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12213,7 +11425,7 @@ suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableEnum16Attribute( @@ -12221,120 +11433,112 @@ suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16406u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableEnum16AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableEnum16AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenum16 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableenum16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableEnum16AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableEnum16AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableEnum16AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute {val ATTRIBUTE_ID: UInt = 16407u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute { + val ATTRIBUTE_ID: UInt = 16407u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablefloatsingle attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablefloatsingle attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - tlvReader.getFloat(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + tlvReader.getFloat(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableFloatSingleAttribute(decodedValue) } - suspend fun writeNullableFloatSingleAttribute( - value: Float, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableFloatSingleAttribute(value: Float, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16407u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12356,7 +11560,7 @@ suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableFloatSingleAttribute( @@ -12364,120 +11568,115 @@ suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16407u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableFloatSingleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableFloatSingleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablefloatsingle attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablefloatsingle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - tlvReader.getFloat(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = + if (!tlvReader.isNull()) { + tlvReader.getFloat(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableFloatSingleAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableFloatSingleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableFloatSingleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute {val ATTRIBUTE_ID: UInt = 16408u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute { + val ATTRIBUTE_ID: UInt = 16408u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablefloatdouble attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablefloatdouble attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Double? = if (!tlvReader.isNull()) { - tlvReader.getDouble(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Double? = + if (!tlvReader.isNull()) { + tlvReader.getDouble(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableFloatDoubleAttribute(decodedValue) } suspend fun writeNullableFloatDoubleAttribute( value: Double, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16408u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12499,7 +11698,7 @@ suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableFloatDoubleAttribute( @@ -12507,120 +11706,115 @@ suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16408u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableFloatDoubleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableFloatDoubleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablefloatdouble attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablefloatdouble attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Double? = if (!tlvReader.isNull()) { - tlvReader.getDouble(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Double? = + if (!tlvReader.isNull()) { + tlvReader.getDouble(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableFloatDoubleAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableFloatDoubleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableFloatDoubleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute {val ATTRIBUTE_ID: UInt = 16409u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 16409u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableOctetStringAttribute(decodedValue) } suspend fun writeNullableOctetStringAttribute( value: ByteArray, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16409u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12642,7 +11836,7 @@ suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableOctetStringAttribute( @@ -12650,120 +11844,112 @@ suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16409u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableOctetStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableOctetStringAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableOctetStringAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute {val ATTRIBUTE_ID: UInt = 16414u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute { + val ATTRIBUTE_ID: UInt = 16414u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablecharstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablecharstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableCharStringAttribute(decodedValue) } - suspend fun writeNullableCharStringAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableCharStringAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16414u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12785,7 +11971,7 @@ suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute {val throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableCharStringAttribute( @@ -12793,120 +11979,112 @@ suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16414u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableCharStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableCharStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablecharstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablecharstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableCharStringAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableCharStringAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableCharStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute {val ATTRIBUTE_ID: UInt = 16420u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute { + val ATTRIBUTE_ID: UInt = 16420u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenumattr attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableenumattr attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableEnumAttrAttribute(decodedValue) } - suspend fun writeNullableEnumAttrAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableEnumAttrAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16420u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12928,7 +12106,7 @@ suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableEnumAttrAttribute( @@ -12936,120 +12114,115 @@ suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16420u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableEnumAttrAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableEnumAttrAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenumattr attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableenumattr attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableEnumAttrAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableEnumAttrAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableEnumAttrAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableStructAttribute(): NullableStructAttribute {val ATTRIBUTE_ID: UInt = 16421u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableStructAttribute(): NullableStructAttribute { + val ATTRIBUTE_ID: UInt = 16421u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablestruct attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablestruct attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct? = if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UnitTestingClusterSimpleStruct? = + if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableStructAttribute(decodedValue) } suspend fun writeNullableStructAttribute( value: UnitTestingClusterSimpleStruct, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16421u val tlvWriter = TlvWriter() - value.toTlv(AnonymousTag, tlvWriter) + value.toTlv(AnonymousTag, tlvWriter) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13071,7 +12244,7 @@ suspend fun readNullableStructAttribute(): NullableStructAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableStructAttribute( @@ -13079,120 +12252,115 @@ suspend fun readNullableStructAttribute(): NullableStructAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16421u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableStructAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableStructAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablestruct attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablestruct attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct? = if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UnitTestingClusterSimpleStruct? = + if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableStructAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableStructAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableStructAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestrictedInt8uAttribute {val ATTRIBUTE_ID: UInt = 16422u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestrictedInt8uAttribute { + val ATTRIBUTE_ID: UInt = 16422u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablerangerestrictedint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableRangeRestrictedInt8uAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt8uAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16422u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13214,7 +12382,7 @@ suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestricted throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt8uAttribute( @@ -13222,120 +12390,117 @@ suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestricted maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16422u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableRangeRestrictedInt8uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableRangeRestrictedInt8uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt8uAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt8uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestrictedInt8sAttribute {val ATTRIBUTE_ID: UInt = 16423u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestrictedInt8sAttribute { + val ATTRIBUTE_ID: UInt = 16423u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablerangerestrictedint8s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableRangeRestrictedInt8sAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt8sAttribute( value: Byte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16423u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13357,7 +12522,7 @@ suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestricted throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt8sAttribute( @@ -13365,120 +12530,119 @@ suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestricted maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16423u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableRangeRestrictedInt8sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableRangeRestrictedInt8sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt8sAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt8sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestrictedInt16uAttribute {val ATTRIBUTE_ID: UInt = 16424u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestrictedInt16uAttribute { + val ATTRIBUTE_ID: UInt = 16424u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16u attribute not found in response" + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableRangeRestrictedInt16uAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt16uAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16424u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13500,7 +12664,7 @@ suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestricte throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt16uAttribute( @@ -13508,120 +12672,119 @@ suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestricte maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16424u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableRangeRestrictedInt16uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableRangeRestrictedInt16uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt16uAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt16uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestrictedInt16sAttribute {val ATTRIBUTE_ID: UInt = 16425u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestrictedInt16sAttribute { + val ATTRIBUTE_ID: UInt = 16425u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16s attribute not found in response" + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableRangeRestrictedInt16sAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt16sAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16425u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13643,7 +12806,7 @@ suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestricte throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt16sAttribute( @@ -13651,119 +12814,113 @@ suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestricte maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16425u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableRangeRestrictedInt16sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableRangeRestrictedInt16sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt16sAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt16sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWriteOnlyInt8uAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16426u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWriteOnlyInt8uAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16426u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Writeonlyint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Writeonlyint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWriteOnlyInt8uAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeWriteOnlyInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16426u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13785,7 +12942,7 @@ suspend fun readWriteOnlyInt8uAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1642 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWriteOnlyInt8uAttribute( @@ -13793,114 +12950,105 @@ suspend fun readWriteOnlyInt8uAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1642 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16426u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Writeonlyint8u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Writeonlyint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeiInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4294070017u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeiInt8uAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4294070017u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Meiint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Meiint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeMeiInt8uAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeMeiInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4294070017u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13922,7 +13070,7 @@ suspend fun readMeiInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4294070017u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMeiInt8uAttribute( @@ -13930,35 +13078,37 @@ suspend fun readMeiInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4294070017u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4294070017u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Meiint8u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Meiint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -13970,49 +13120,43 @@ suspend fun readMeiInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4294070017u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -14022,45 +13166,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -14068,49 +13217,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -14120,45 +13263,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -14166,49 +13314,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -14218,45 +13360,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -14264,49 +13409,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -14316,45 +13455,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -14362,44 +13504,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -14408,35 +13543,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -14448,44 +13585,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -14494,34 +13624,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -14534,7 +13668,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt index b7fb44b39973dc..df0867a6902b61 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt @@ -17,182 +17,140 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UserLabelCluster(private val controller: MatterController, private val endpointId: UShort) {class LabelListAttribute( - val value: List - ) +class UserLabelCluster(private val controller: MatterController, private val endpointId: UShort) { + class LabelListAttribute(val value: List) sealed class LabelListAttributeSubscriptionState { - data class Success( - val value: List - ) : LabelListAttributeSubscriptionState() - + data class Success(val value: List) : + LabelListAttributeSubscriptionState() + data class Error(val exception: Exception) : LabelListAttributeSubscriptionState() - object SubscriptionEstablished : LabelListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LabelListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readLabelListAttribute(): LabelListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Labellist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Labellist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return LabelListAttribute(decodedValue) } suspend fun writeLabelListAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -214,7 +172,7 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLabelListAttribute( @@ -222,45 +180,48 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LabelListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LabelListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Labellist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Labellist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(LabelListAttributeSubscriptionState.Success(decodedValue)) } @@ -268,49 +229,43 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt emit(LabelListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -320,45 +275,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -366,49 +326,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -418,45 +372,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -464,49 +423,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -516,45 +469,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -562,49 +518,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -614,45 +564,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -660,44 +613,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -706,35 +652,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -746,44 +694,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -792,34 +733,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -832,7 +777,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt index b4b18cde045376..6160dd924179e6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt @@ -17,222 +17,167 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlCluster(private val controller: MatterController, private val endpointId: UShort) {class OpenDurationAttribute( - val value: UInt? - ) +class ValveConfigurationAndControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class OpenDurationAttribute(val value: UInt?) sealed class OpenDurationAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : OpenDurationAttributeSubscriptionState() - + data class Success(val value: UInt?) : OpenDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : OpenDurationAttributeSubscriptionState() - object SubscriptionEstablished : OpenDurationAttributeSubscriptionState() - } -class DefaultOpenDurationAttribute( - val value: UInt? - ) + object SubscriptionEstablished : OpenDurationAttributeSubscriptionState() + } + + class DefaultOpenDurationAttribute(val value: UInt?) sealed class DefaultOpenDurationAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : DefaultOpenDurationAttributeSubscriptionState() - + data class Success(val value: UInt?) : DefaultOpenDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultOpenDurationAttributeSubscriptionState() - object SubscriptionEstablished : DefaultOpenDurationAttributeSubscriptionState() - } -class AutoCloseTimeAttribute( - val value: ULong? - ) + object SubscriptionEstablished : DefaultOpenDurationAttributeSubscriptionState() + } + + class AutoCloseTimeAttribute(val value: ULong?) sealed class AutoCloseTimeAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : AutoCloseTimeAttributeSubscriptionState() - + data class Success(val value: ULong?) : AutoCloseTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : AutoCloseTimeAttributeSubscriptionState() - object SubscriptionEstablished : AutoCloseTimeAttributeSubscriptionState() - } -class RemainingDurationAttribute( - val value: UInt? - ) + object SubscriptionEstablished : AutoCloseTimeAttributeSubscriptionState() + } + + class RemainingDurationAttribute(val value: UInt?) sealed class RemainingDurationAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : RemainingDurationAttributeSubscriptionState() - + data class Success(val value: UInt?) : RemainingDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : RemainingDurationAttributeSubscriptionState() - object SubscriptionEstablished : RemainingDurationAttributeSubscriptionState() - } -class CurrentStateAttribute( - val value: UByte? - ) + object SubscriptionEstablished : RemainingDurationAttributeSubscriptionState() + } + + class CurrentStateAttribute(val value: UByte?) sealed class CurrentStateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentStateAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentStateAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentStateAttributeSubscriptionState() - object SubscriptionEstablished : CurrentStateAttributeSubscriptionState() - } -class TargetStateAttribute( - val value: UByte? - ) + object SubscriptionEstablished : CurrentStateAttributeSubscriptionState() + } + + class TargetStateAttribute(val value: UByte?) sealed class TargetStateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : TargetStateAttributeSubscriptionState() - + data class Success(val value: UByte?) : TargetStateAttributeSubscriptionState() + data class Error(val exception: Exception) : TargetStateAttributeSubscriptionState() - object SubscriptionEstablished : TargetStateAttributeSubscriptionState() - } -class CurrentLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : TargetStateAttributeSubscriptionState() + } + + class CurrentLevelAttribute(val value: UByte?) sealed class CurrentLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentLevelAttributeSubscriptionState() - object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() - } -class TargetLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() + } + + class TargetLevelAttribute(val value: UByte?) sealed class TargetLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : TargetLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : TargetLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : TargetLevelAttributeSubscriptionState() - object SubscriptionEstablished : TargetLevelAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : TargetLevelAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun open(openDuration: UInt? - ,targetLevel: UByte? - ,timedInvokeTimeout: Duration? = null) { + suspend fun open(openDuration: UInt?, targetLevel: UByte?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_OPEN_DURATION_REQ: Int = 0 - openDuration?.let { - tlvWriter.put(ContextSpecificTag(TAG_OPEN_DURATION_REQ), openDuration) - } + openDuration?.let { tlvWriter.put(ContextSpecificTag(TAG_OPEN_DURATION_REQ), openDuration) } val TAG_TARGET_LEVEL_REQ: Int = 1 - targetLevel?.let { - tlvWriter.put(ContextSpecificTag(TAG_TARGET_LEVEL_REQ), targetLevel) - } + targetLevel?.let { tlvWriter.put(ContextSpecificTag(TAG_TARGET_LEVEL_REQ), targetLevel) } tlvWriter.endStructure() val request: InvokeRequest = @@ -250,7 +195,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -263,46 +208,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readOpenDurationAttribute(): OpenDurationAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOpenDurationAttribute(): OpenDurationAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Openduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Openduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return OpenDurationAttribute(decodedValue) } @@ -312,120 +251,110 @@ suspend fun readOpenDurationAttribute(): OpenDurationAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OpenDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OpenDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Openduration attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Openduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OpenDurationAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OpenDurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OpenDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultopenduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultopenduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return DefaultOpenDurationAttribute(decodedValue) } - suspend fun writeDefaultOpenDurationAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultOpenDurationAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -447,7 +376,7 @@ suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultOpenDurationAttribute( @@ -455,100 +384,96 @@ suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DefaultOpenDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DefaultOpenDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultopenduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultopenduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DefaultOpenDurationAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DefaultOpenDurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DefaultOpenDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Autoclosetime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Autoclosetime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AutoCloseTimeAttribute(decodedValue) } @@ -558,100 +483,94 @@ suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AutoCloseTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AutoCloseTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Autoclosetime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Autoclosetime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AutoCloseTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AutoCloseTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AutoCloseTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remainingduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return RemainingDurationAttribute(decodedValue) } @@ -661,96 +580,92 @@ suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RemainingDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RemainingDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Remainingduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(RemainingDurationAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RemainingDurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RemainingDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentStateAttribute(): CurrentStateAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentStateAttribute(): CurrentStateAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentStateAttribute(decodedValue) } @@ -760,96 +675,90 @@ suspend fun readCurrentStateAttribute(): CurrentStateAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentStateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentStateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentStateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetStateAttribute(): TargetStateAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTargetStateAttribute(): TargetStateAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Targetstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return TargetStateAttribute(decodedValue) } @@ -859,100 +768,94 @@ suspend fun readTargetStateAttribute(): TargetStateAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetStateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Targetstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(TargetStateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(TargetStateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TargetStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentLevelAttribute(decodedValue) } @@ -962,104 +865,98 @@ suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentLevelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetLevelAttribute(): TargetLevelAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTargetLevelAttribute(): TargetLevelAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Targetlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TargetLevelAttribute(decodedValue) } @@ -1069,123 +966,113 @@ suspend fun readTargetLevelAttribute(): TargetLevelAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Targetlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(TargetLevelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(TargetLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TargetLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultOpenLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultOpenLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultopenlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultopenlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeDefaultOpenLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultOpenLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1207,7 +1094,7 @@ suspend fun readDefaultOpenLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultOpenLevelAttribute( @@ -1215,94 +1102,90 @@ suspend fun readDefaultOpenLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultopenlevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultopenlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readValveFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readValveFaultAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Valvefault attribute not found in response" - } + } + + requireNotNull(attributeData) { "Valvefault attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1312,94 +1195,88 @@ suspend fun readValveFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Valvefault attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Valvefault attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelStepAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelstep attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelstep attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1409,96 +1286,90 @@ suspend fun readLevelStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelstep attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelstep attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1508,45 +1379,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1554,49 +1430,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1606,45 +1476,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1652,49 +1527,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1704,45 +1573,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1750,49 +1622,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1802,45 +1668,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1848,44 +1717,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1894,35 +1756,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1934,44 +1798,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1980,34 +1837,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2020,7 +1881,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt index 18d648654b3557..b29d8ae7c59bd6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt @@ -17,139 +17,98 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.ByteArraySubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class WakeOnLanCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class WakeOnLanCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMACAddressAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMACAddressAttribute(): String? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Macaddress attribute not found in response" - } + } + + requireNotNull(attributeData) { "Macaddress attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -159,94 +118,88 @@ suspend fun readMACAddressAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Macaddress attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Macaddress attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLinkLocalAddressAttribute(): ByteArray? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLinkLocalAddressAttribute(): ByteArray? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linklocaladdress attribute not found in response" - } + } + + requireNotNull(attributeData) { "Linklocaladdress attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - + val decodedValue: ByteArray? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } return decodedValue } @@ -256,96 +209,92 @@ suspend fun readLinkLocalAddressAttribute(): ByteArray? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteArraySubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linklocaladdress attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Linklocaladdress attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ByteArraySubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ByteArraySubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -355,45 +304,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -401,49 +355,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -453,45 +401,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -499,49 +452,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -551,45 +498,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -597,49 +547,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -649,45 +593,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -695,44 +642,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -741,35 +681,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -781,44 +723,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -827,34 +762,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -867,7 +806,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt index a863a7bdcbe2f5..a5a3c4300e4829 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt @@ -17,275 +17,206 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class BssidAttribute( - val value: ByteArray? - ) +class WiFiNetworkDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class BssidAttribute(val value: ByteArray?) sealed class BssidAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : BssidAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : BssidAttributeSubscriptionState() + data class Error(val exception: Exception) : BssidAttributeSubscriptionState() - object SubscriptionEstablished : BssidAttributeSubscriptionState() - } -class SecurityTypeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : BssidAttributeSubscriptionState() + } + + class SecurityTypeAttribute(val value: UByte?) sealed class SecurityTypeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : SecurityTypeAttributeSubscriptionState() - + data class Success(val value: UByte?) : SecurityTypeAttributeSubscriptionState() + data class Error(val exception: Exception) : SecurityTypeAttributeSubscriptionState() - object SubscriptionEstablished : SecurityTypeAttributeSubscriptionState() - } -class WiFiVersionAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SecurityTypeAttributeSubscriptionState() + } + + class WiFiVersionAttribute(val value: UByte?) sealed class WiFiVersionAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : WiFiVersionAttributeSubscriptionState() - + data class Success(val value: UByte?) : WiFiVersionAttributeSubscriptionState() + data class Error(val exception: Exception) : WiFiVersionAttributeSubscriptionState() - object SubscriptionEstablished : WiFiVersionAttributeSubscriptionState() - } -class ChannelNumberAttribute( - val value: UShort? - ) + object SubscriptionEstablished : WiFiVersionAttributeSubscriptionState() + } + + class ChannelNumberAttribute(val value: UShort?) sealed class ChannelNumberAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : ChannelNumberAttributeSubscriptionState() - + data class Success(val value: UShort?) : ChannelNumberAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelNumberAttributeSubscriptionState() - object SubscriptionEstablished : ChannelNumberAttributeSubscriptionState() - } -class RssiAttribute( - val value: Byte? - ) + object SubscriptionEstablished : ChannelNumberAttributeSubscriptionState() + } + + class RssiAttribute(val value: Byte?) sealed class RssiAttributeSubscriptionState { - data class Success( - val value: Byte? - ) : RssiAttributeSubscriptionState() - + data class Success(val value: Byte?) : RssiAttributeSubscriptionState() + data class Error(val exception: Exception) : RssiAttributeSubscriptionState() - object SubscriptionEstablished : RssiAttributeSubscriptionState() - } -class BeaconLostCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : RssiAttributeSubscriptionState() + } + + class BeaconLostCountAttribute(val value: UInt?) sealed class BeaconLostCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BeaconLostCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : BeaconLostCountAttributeSubscriptionState() + data class Error(val exception: Exception) : BeaconLostCountAttributeSubscriptionState() - object SubscriptionEstablished : BeaconLostCountAttributeSubscriptionState() - } -class BeaconRxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : BeaconLostCountAttributeSubscriptionState() + } + + class BeaconRxCountAttribute(val value: UInt?) sealed class BeaconRxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BeaconRxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : BeaconRxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : BeaconRxCountAttributeSubscriptionState() - object SubscriptionEstablished : BeaconRxCountAttributeSubscriptionState() - } -class PacketMulticastRxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : BeaconRxCountAttributeSubscriptionState() + } + + class PacketMulticastRxCountAttribute(val value: UInt?) sealed class PacketMulticastRxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PacketMulticastRxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : PacketMulticastRxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketMulticastRxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketMulticastRxCountAttributeSubscriptionState() - } -class PacketMulticastTxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PacketMulticastRxCountAttributeSubscriptionState() + } + + class PacketMulticastTxCountAttribute(val value: UInt?) sealed class PacketMulticastTxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PacketMulticastTxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : PacketMulticastTxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketMulticastTxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketMulticastTxCountAttributeSubscriptionState() - } -class PacketUnicastRxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PacketMulticastTxCountAttributeSubscriptionState() + } + + class PacketUnicastRxCountAttribute(val value: UInt?) sealed class PacketUnicastRxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PacketUnicastRxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : PacketUnicastRxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketUnicastRxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketUnicastRxCountAttributeSubscriptionState() - } -class PacketUnicastTxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PacketUnicastRxCountAttributeSubscriptionState() + } + + class PacketUnicastTxCountAttribute(val value: UInt?) sealed class PacketUnicastTxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PacketUnicastTxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : PacketUnicastTxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketUnicastTxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketUnicastTxCountAttributeSubscriptionState() - } -class CurrentMaxRateAttribute( - val value: ULong? - ) + object SubscriptionEstablished : PacketUnicastTxCountAttributeSubscriptionState() + } + + class CurrentMaxRateAttribute(val value: ULong?) sealed class CurrentMaxRateAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : CurrentMaxRateAttributeSubscriptionState() - + data class Success(val value: ULong?) : CurrentMaxRateAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentMaxRateAttributeSubscriptionState() - object SubscriptionEstablished : CurrentMaxRateAttributeSubscriptionState() - } -class OverrunCountAttribute( - val value: ULong? - ) + object SubscriptionEstablished : CurrentMaxRateAttributeSubscriptionState() + } + + class OverrunCountAttribute(val value: ULong?) sealed class OverrunCountAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : OverrunCountAttributeSubscriptionState() - + data class Success(val value: ULong?) : OverrunCountAttributeSubscriptionState() + data class Error(val exception: Exception) : OverrunCountAttributeSubscriptionState() - object SubscriptionEstablished : OverrunCountAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OverrunCountAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCounts(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -298,46 +229,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readBssidAttribute(): BssidAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBssidAttribute(): BssidAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bssid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bssid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return BssidAttribute(decodedValue) } @@ -347,96 +272,90 @@ suspend fun readBssidAttribute(): BssidAttribute {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BssidAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BssidAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bssid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bssid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BssidAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BssidAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BssidAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Securitytype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Securitytype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SecurityTypeAttribute(decodedValue) } @@ -446,96 +365,90 @@ suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SecurityTypeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SecurityTypeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Securitytype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Securitytype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SecurityTypeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SecurityTypeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SecurityTypeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wifiversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wifiversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return WiFiVersionAttribute(decodedValue) } @@ -545,96 +458,90 @@ suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WiFiVersionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WiFiVersionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wifiversion attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Wifiversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(WiFiVersionAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(WiFiVersionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(WiFiVersionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChannelNumberAttribute(): ChannelNumberAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readChannelNumberAttribute(): ChannelNumberAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channelnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Channelnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ChannelNumberAttribute(decodedValue) } @@ -644,96 +551,90 @@ suspend fun readChannelNumberAttribute(): ChannelNumberAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChannelNumberAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChannelNumberAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channelnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Channelnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ChannelNumberAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ChannelNumberAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChannelNumberAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRssiAttribute(): RssiAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRssiAttribute(): RssiAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rssi attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rssi attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return RssiAttribute(decodedValue) } @@ -743,100 +644,94 @@ suspend fun readRssiAttribute(): RssiAttribute {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RssiAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RssiAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rssi attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rssi attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(RssiAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RssiAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RssiAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Beaconlostcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Beaconlostcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BeaconLostCountAttribute(decodedValue) } @@ -846,104 +741,100 @@ suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BeaconLostCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BeaconLostCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Beaconlostcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Beaconlostcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BeaconLostCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BeaconLostCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BeaconLostCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Beaconrxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Beaconrxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BeaconRxCountAttribute(decodedValue) } @@ -953,104 +844,98 @@ suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BeaconRxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BeaconRxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Beaconrxcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Beaconrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BeaconRxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BeaconRxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BeaconRxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetmulticastrxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetmulticastrxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PacketMulticastRxCountAttribute(decodedValue) } @@ -1060,104 +945,100 @@ suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PacketMulticastRxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PacketMulticastRxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetmulticastrxcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Packetmulticastrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PacketMulticastRxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PacketMulticastRxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PacketMulticastRxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribute {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetmulticasttxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetmulticasttxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PacketMulticastTxCountAttribute(decodedValue) } @@ -1167,104 +1048,100 @@ suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PacketMulticastTxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PacketMulticastTxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetmulticasttxcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Packetmulticasttxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PacketMulticastTxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PacketMulticastTxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PacketMulticastTxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetunicastrxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetunicastrxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PacketUnicastRxCountAttribute(decodedValue) } @@ -1274,104 +1151,100 @@ suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PacketUnicastRxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PacketUnicastRxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetunicastrxcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Packetunicastrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PacketUnicastRxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PacketUnicastRxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PacketUnicastRxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetunicasttxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetunicasttxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PacketUnicastTxCountAttribute(decodedValue) } @@ -1381,104 +1254,100 @@ suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PacketUnicastTxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PacketUnicastTxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetunicasttxcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Packetunicasttxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PacketUnicastTxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PacketUnicastTxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PacketUnicastTxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmaxrate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmaxrate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentMaxRateAttribute(decodedValue) } @@ -1488,104 +1357,100 @@ suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentMaxRateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentMaxRateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmaxrate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentmaxrate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentMaxRateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentMaxRateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentMaxRateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOverrunCountAttribute(): OverrunCountAttribute {val ATTRIBUTE_ID: UInt = 12u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOverrunCountAttribute(): OverrunCountAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Overruncount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OverrunCountAttribute(decodedValue) } @@ -1595,101 +1460,95 @@ suspend fun readOverrunCountAttribute(): OverrunCountAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OverrunCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OverrunCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Overruncount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OverrunCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OverrunCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OverrunCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1699,45 +1558,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1745,49 +1609,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1797,45 +1655,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1843,49 +1706,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1895,45 +1752,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1941,49 +1801,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1993,45 +1847,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2039,44 +1896,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2085,35 +1935,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2125,44 +1977,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2171,34 +2016,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2211,7 +2060,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkManagementCluster.kt index a864b2c8dbbdf3..5deb4b8317d3a4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkManagementCluster.kt @@ -17,123 +17,91 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkManagementCluster(private val controller: MatterController, private val endpointId: UShort) { - class NetworkPassphraseResponse( - val passphrase: ByteArray - ) -class SsidAttribute( - val value: ByteArray? - ) +class WiFiNetworkManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class NetworkPassphraseResponse(val passphrase: ByteArray) + + class SsidAttribute(val value: ByteArray?) sealed class SsidAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : SsidAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : SsidAttributeSubscriptionState() + data class Error(val exception: Exception) : SsidAttributeSubscriptionState() - object SubscriptionEstablished : SsidAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SsidAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun networkPassphraseRequest(timedInvokeTimeout: Duration? = null): NetworkPassphraseResponse { + suspend fun networkPassphraseRequest( + timedInvokeTimeout: Duration? = null + ): NetworkPassphraseResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -150,73 +118,59 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_PASSPHRASE: Int = 0 var passphrase_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_PASSPHRASE)) {passphrase_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_PASSPHRASE)) { + passphrase_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (passphrase_decoded == null) { - throw IllegalStateException("passphrase not found in TLV") + throw IllegalStateException("passphrase not found in TLV") } - tlvReader.exitContainer() - return NetworkPassphraseResponse( - passphrase_decoded - ) + return NetworkPassphraseResponse(passphrase_decoded) } -suspend fun readSsidAttribute(): SsidAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSsidAttribute(): SsidAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ssid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ssid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SsidAttribute(decodedValue) } @@ -226,97 +180,91 @@ suspend fun readSsidAttribute(): SsidAttribute {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SsidAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SsidAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ssid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Ssid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SsidAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SsidAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SsidAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -326,45 +274,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -372,49 +325,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -424,45 +371,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -470,49 +422,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -522,45 +468,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -568,49 +517,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -620,45 +563,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -666,44 +612,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -712,35 +651,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -752,44 +693,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -798,34 +732,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -838,7 +776,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt index d47645e5b75dca..7fb2facd9cc45b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt @@ -17,210 +17,173 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WindowCoveringCluster(private val controller: MatterController, private val endpointId: UShort) {class CurrentPositionLiftAttribute( - val value: UShort? - ) +class WindowCoveringCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class CurrentPositionLiftAttribute(val value: UShort?) sealed class CurrentPositionLiftAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : CurrentPositionLiftAttributeSubscriptionState() - + data class Success(val value: UShort?) : CurrentPositionLiftAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPositionLiftAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPositionLiftAttributeSubscriptionState() - } -class CurrentPositionTiltAttribute( - val value: UShort? - ) + object SubscriptionEstablished : CurrentPositionLiftAttributeSubscriptionState() + } + + class CurrentPositionTiltAttribute(val value: UShort?) sealed class CurrentPositionTiltAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : CurrentPositionTiltAttributeSubscriptionState() - + data class Success(val value: UShort?) : CurrentPositionTiltAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPositionTiltAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPositionTiltAttributeSubscriptionState() - } -class CurrentPositionLiftPercentageAttribute( - val value: UByte? - ) + object SubscriptionEstablished : CurrentPositionTiltAttributeSubscriptionState() + } + + class CurrentPositionLiftPercentageAttribute(val value: UByte?) sealed class CurrentPositionLiftPercentageAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPositionLiftPercentageAttributeSubscriptionState() - - data class Error(val exception: Exception) : CurrentPositionLiftPercentageAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionLiftPercentageAttributeSubscriptionState() - } -class CurrentPositionTiltPercentageAttribute( - val value: UByte? - ) + data class Success(val value: UByte?) : + CurrentPositionLiftPercentageAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CurrentPositionLiftPercentageAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionLiftPercentageAttributeSubscriptionState() + } + + class CurrentPositionTiltPercentageAttribute(val value: UByte?) sealed class CurrentPositionTiltPercentageAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPositionTiltPercentageAttributeSubscriptionState() - - data class Error(val exception: Exception) : CurrentPositionTiltPercentageAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionTiltPercentageAttributeSubscriptionState() - } -class TargetPositionLiftPercent100thsAttribute( - val value: UShort? - ) + data class Success(val value: UByte?) : + CurrentPositionTiltPercentageAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CurrentPositionTiltPercentageAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionTiltPercentageAttributeSubscriptionState() + } + + class TargetPositionLiftPercent100thsAttribute(val value: UShort?) sealed class TargetPositionLiftPercent100thsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : TargetPositionLiftPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : TargetPositionLiftPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : TargetPositionLiftPercent100thsAttributeSubscriptionState() - } -class TargetPositionTiltPercent100thsAttribute( - val value: UShort? - ) + data class Success(val value: UShort?) : + TargetPositionLiftPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + TargetPositionLiftPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : TargetPositionLiftPercent100thsAttributeSubscriptionState() + } + + class TargetPositionTiltPercent100thsAttribute(val value: UShort?) sealed class TargetPositionTiltPercent100thsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : TargetPositionTiltPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : TargetPositionTiltPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : TargetPositionTiltPercent100thsAttributeSubscriptionState() - } -class CurrentPositionLiftPercent100thsAttribute( - val value: UShort? - ) + data class Success(val value: UShort?) : + TargetPositionTiltPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + TargetPositionTiltPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : TargetPositionTiltPercent100thsAttributeSubscriptionState() + } + + class CurrentPositionLiftPercent100thsAttribute(val value: UShort?) sealed class CurrentPositionLiftPercent100thsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : CurrentPositionLiftPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : CurrentPositionLiftPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionLiftPercent100thsAttributeSubscriptionState() - } -class CurrentPositionTiltPercent100thsAttribute( - val value: UShort? - ) + data class Success(val value: UShort?) : + CurrentPositionLiftPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CurrentPositionLiftPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionLiftPercent100thsAttributeSubscriptionState() + } + + class CurrentPositionTiltPercent100thsAttribute(val value: UShort?) sealed class CurrentPositionTiltPercent100thsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : CurrentPositionTiltPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : CurrentPositionTiltPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionTiltPercent100thsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: UShort?) : + CurrentPositionTiltPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CurrentPositionTiltPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionTiltPercent100thsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun upOrOpen(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -238,7 +201,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -256,7 +219,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -270,15 +233,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToLiftValue(liftValue: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun goToLiftValue(liftValue: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LIFT_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LIFT_VALUE_REQ), liftValue) + tlvWriter.put(ContextSpecificTag(TAG_LIFT_VALUE_REQ), liftValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -292,15 +254,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToLiftPercentage(liftPercent100thsValue: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun goToLiftPercentage( + liftPercent100thsValue: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LIFT_PERCENT100THS_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LIFT_PERCENT100THS_VALUE_REQ), liftPercent100thsValue) + tlvWriter.put(ContextSpecificTag(TAG_LIFT_PERCENT100THS_VALUE_REQ), liftPercent100thsValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -314,15 +278,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToTiltValue(tiltValue: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun goToTiltValue(tiltValue: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 7u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TILT_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TILT_VALUE_REQ), tiltValue) + tlvWriter.put(ContextSpecificTag(TAG_TILT_VALUE_REQ), tiltValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -336,15 +299,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToTiltPercentage(tiltPercent100thsValue: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun goToTiltPercentage( + tiltPercent100thsValue: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TILT_PERCENT100THS_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TILT_PERCENT100THS_VALUE_REQ), tiltPercent100thsValue) + tlvWriter.put(ContextSpecificTag(TAG_TILT_PERCENT100THS_VALUE_REQ), tiltPercent100thsValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -357,42 +322,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Type attribute not found in response" - } + } + + requireNotNull(attributeData) { "Type attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -401,35 +359,37 @@ suspend fun readTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Type attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Type attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -441,47 +401,41 @@ suspend fun readTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPhysicalClosedLimitLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalclosedlimitlift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Physicalclosedlimitlift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -491,94 +445,90 @@ suspend fun readPhysicalClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalclosedlimitlift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalclosedlimitlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPhysicalClosedLimitTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalclosedlimittilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Physicalclosedlimittilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -588,99 +538,95 @@ suspend fun readPhysicalClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalclosedlimittilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalclosedlimittilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionlift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentpositionlift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionLiftAttribute(decodedValue) } @@ -690,104 +636,100 @@ suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionLiftAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionLiftAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionlift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositionlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPositionLiftAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPositionLiftAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionLiftAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentpositiontilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionTiltAttribute(decodedValue) } @@ -797,99 +739,95 @@ suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionTiltAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionTiltAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositiontilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPositionTiltAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPositionTiltAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionTiltAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfActuationsLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfActuationsLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofactuationslift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofactuationslift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -899,94 +837,90 @@ suspend fun readNumberOfActuationsLiftAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofactuationslift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofactuationslift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfActuationsTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfActuationsTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofactuationstilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofactuationstilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -996,91 +930,86 @@ suspend fun readNumberOfActuationsTiltAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofactuationstilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofactuationstilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readConfigStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readConfigStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Configstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Configstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1089,35 +1018,37 @@ suspend fun readConfigStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Configstatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Configstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1129,52 +1060,48 @@ suspend fun readConfigStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPercentageAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPercentageAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercentage attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositionliftpercentage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionLiftPercentageAttribute(decodedValue) } @@ -1184,104 +1111,104 @@ suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPer maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionLiftPercentageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionLiftPercentageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercentage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositionliftpercentage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionLiftPercentageAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionLiftPercentageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPercentageAttribute {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPercentageAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercentage attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercentage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionTiltPercentageAttribute(decodedValue) } @@ -1291,96 +1218,93 @@ suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPer maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionTiltPercentageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionTiltPercentageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercentage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositiontiltpercentage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionTiltPercentageAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionTiltPercentageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOperationalStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1389,34 +1313,38 @@ suspend fun readOperationalStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatus attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1429,52 +1357,49 @@ suspend fun readOperationalStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetPositionLiftPercent100thsAttribute(): TargetPositionLiftPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTargetPositionLiftPercent100thsAttribute(): + TargetPositionLiftPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetpositionliftpercent100ths attribute not found in response" + } + + requireNotNull(attributeData) { + "Targetpositionliftpercent100ths attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TargetPositionLiftPercent100thsAttribute(decodedValue) } @@ -1484,104 +1409,105 @@ suspend fun readTargetPositionLiftPercent100thsAttribute(): TargetPositionLiftPe maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetPositionLiftPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetPositionLiftPercent100thsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetpositionliftpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Targetpositionliftpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(TargetPositionLiftPercent100thsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(TargetPositionLiftPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetPositionTiltPercent100thsAttribute(): TargetPositionTiltPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTargetPositionTiltPercent100thsAttribute(): + TargetPositionTiltPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetpositiontiltpercent100ths attribute not found in response" - } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null + } + + requireNotNull(attributeData) { + "Targetpositiontiltpercent100ths attribute not found in response" } + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TargetPositionTiltPercent100thsAttribute(decodedValue) } @@ -1591,96 +1517,93 @@ suspend fun readTargetPositionTiltPercent100thsAttribute(): TargetPositionTiltPe maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetPositionTiltPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetPositionTiltPercent100thsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetpositiontiltpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Targetpositiontiltpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(TargetPositionTiltPercent100thsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(TargetPositionTiltPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEndProductTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEndProductTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endproducttype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Endproducttype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1689,34 +1612,38 @@ suspend fun readEndProductTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 13u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endproducttype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Endproducttype attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1729,52 +1656,49 @@ suspend fun readEndProductTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 13u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionLiftPercent100thsAttribute(): CurrentPositionLiftPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionLiftPercent100thsAttribute(): + CurrentPositionLiftPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercent100ths attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositionliftpercent100ths attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionLiftPercent100thsAttribute(decodedValue) } @@ -1784,104 +1708,105 @@ suspend fun readCurrentPositionLiftPercent100thsAttribute(): CurrentPositionLift maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionLiftPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionLiftPercent100thsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositionliftpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionLiftPercent100thsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionLiftPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionTiltPercent100thsAttribute(): CurrentPositionTiltPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionTiltPercent100thsAttribute(): + CurrentPositionTiltPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercent100ths attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercent100ths attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionTiltPercent100thsAttribute(decodedValue) } @@ -1891,99 +1816,97 @@ suspend fun readCurrentPositionTiltPercent100thsAttribute(): CurrentPositionTilt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionTiltPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionTiltPercent100thsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositiontiltpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionTiltPercent100thsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionTiltPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstalledOpenLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstalledOpenLimitLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedopenlimitlift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Installedopenlimitlift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1993,94 +1916,90 @@ suspend fun readInstalledOpenLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedopenlimitlift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Installedopenlimitlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstalledClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstalledClosedLimitLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedclosedlimitlift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Installedclosedlimitlift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2090,94 +2009,90 @@ suspend fun readInstalledClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedclosedlimitlift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Installedclosedlimitlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstalledOpenLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstalledOpenLimitTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedopenlimittilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Installedopenlimittilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2187,94 +2102,90 @@ suspend fun readInstalledOpenLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedopenlimittilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Installedopenlimittilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstalledClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstalledClosedLimitTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedclosedlimittilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Installedclosedlimittilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2284,114 +2195,105 @@ suspend fun readInstalledClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedclosedlimittilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Installedclosedlimittilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2413,7 +2315,7 @@ suspend fun readModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 23u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeModeAttribute( @@ -2421,35 +2323,37 @@ suspend fun readModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 23u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Mode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2461,47 +2365,41 @@ suspend fun readModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 23u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSafetyStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSafetyStatusAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Safetystatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Safetystatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2511,96 +2409,90 @@ suspend fun readSafetyStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Safetystatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Safetystatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2610,45 +2502,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2656,49 +2553,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2708,45 +2599,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2754,49 +2650,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2806,45 +2696,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2852,49 +2745,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2904,45 +2791,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2950,44 +2840,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2996,35 +2879,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3036,44 +2921,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -3082,34 +2960,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3122,7 +3004,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt index 391c1c223d35b1..bd0e6187f24cb5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,32 +70,47 @@ class AccessControlClusterAccessControlEntryChangedEvent( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlEntryChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlEntryChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUByte(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = if (!tlvReader.isNull()) { - matter.controller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = + if (!tlvReader.isNull()) { + matter.controller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv( + ContextSpecificTag(TAG_LATEST_VALUE), + tlvReader + ) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) + return AccessControlClusterAccessControlEntryChangedEvent( + adminNodeID, + adminPasscodeID, + changeType, + latestValue, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt index dafa1269b8e4c2..aa38ea414d325f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -28,7 +26,8 @@ class AccessControlClusterAccessControlExtensionChangedEvent( val adminNodeID: ULong?, val adminPasscodeID: UShort?, val changeType: UByte, - val latestValue: matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, + val latestValue: + matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, val fabricIndex: UByte ) { override fun toString(): String = buildString { @@ -72,32 +71,45 @@ class AccessControlClusterAccessControlExtensionChangedEvent( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlExtensionChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlExtensionChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUByte(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = if (!tlvReader.isNull()) { - matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = + if (!tlvReader.isNull()) { + matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct + .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlExtensionChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) + return AccessControlClusterAccessControlExtensionChangedEvent( + adminNodeID, + adminPasscodeID, + changeType, + latestValue, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt index 4adc0b113c8e01..81e55baf4fe4f7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt @@ -18,15 +18,12 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccountLoginClusterLoggedOutEvent( - val node: Optional -) { +class AccountLoginClusterLoggedOutEvent(val node: Optional) { override fun toString(): String = buildString { append("AccountLoginClusterLoggedOutEvent {\n") append("\tnode : $node\n") @@ -47,14 +44,15 @@ class AccountLoginClusterLoggedOutEvent( companion object { private const val TAG_NODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccountLoginClusterLoggedOutEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccountLoginClusterLoggedOutEvent { tlvReader.enterStructure(tlvTag) - val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - + val node = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return AccountLoginClusterLoggedOutEvent(node) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt index 90612b49fdd1d2..c1c26f5dc71c4a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,13 +54,13 @@ class ActionsClusterActionFailedEvent( private const val TAG_NEW_STATE = 2 private const val TAG_ERROR = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterActionFailedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterActionFailedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUShort(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getUInt(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) val error = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR)) - + tlvReader.exitContainer() return ActionsClusterActionFailedEvent(actionID, invokeID, newState, error) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt index 2cf57936d0421c..25fdc842bf0af1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,12 @@ class ActionsClusterStateChangedEvent( private const val TAG_INVOKE_I_D = 1 private const val TAG_NEW_STATE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUShort(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getUInt(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) - + tlvReader.exitContainer() return ActionsClusterStateChangedEvent(actionID, invokeID, newState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt index 2b909a62b20b6f..ea0e7e1e1004c4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterLeaveEvent( - val fabricIndex: UByte -) { +class BasicInformationClusterLeaveEvent(val fabricIndex: UByte) { override fun toString(): String = buildString { append("BasicInformationClusterLeaveEvent {\n") append("\tfabricIndex : $fabricIndex\n") @@ -44,10 +40,10 @@ class BasicInformationClusterLeaveEvent( companion object { private const val TAG_FABRIC_INDEX = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterLeaveEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterLeaveEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BasicInformationClusterLeaveEvent(fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt index 4bacfa94d86ef9..a6924b859aa024 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterReachableChangedEvent( - val reachableNewValue: Boolean -) { +class BasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { override fun toString(): String = buildString { append("BasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") @@ -44,10 +40,10 @@ class BasicInformationClusterReachableChangedEvent( companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterReachableChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt index 949ae5f92688a0..fff1d76a1fa86e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterStartUpEvent( - val softwareVersion: UInt -) { +class BasicInformationClusterStartUpEvent(val softwareVersion: UInt) { override fun toString(): String = buildString { append("BasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") @@ -44,10 +40,10 @@ class BasicInformationClusterStartUpEvent( companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterStartUpEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt index 50b4494eebdc0d..82db9ecdb2a8f4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateClusterStateChangeEvent( - val stateValue: Boolean -) { +class BooleanStateClusterStateChangeEvent(val stateValue: Boolean) { override fun toString(): String = buildString { append("BooleanStateClusterStateChangeEvent {\n") append("\tstateValue : $stateValue\n") @@ -44,10 +40,10 @@ class BooleanStateClusterStateChangeEvent( companion object { private const val TAG_STATE_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateClusterStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BooleanStateClusterStateChangeEvent { tlvReader.enterStructure(tlvTag) val stateValue = tlvReader.getBoolean(ContextSpecificTag(TAG_STATE_VALUE)) - + tlvReader.exitContainer() return BooleanStateClusterStateChangeEvent(stateValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt index 14d64045516493..f6777c819c9a57 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,15 +50,19 @@ class BooleanStateConfigurationClusterAlarmsStateChangedEvent( private const val TAG_ALARMS_ACTIVE = 0 private const val TAG_ALARMS_SUPPRESSED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterAlarmsStateChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BooleanStateConfigurationClusterAlarmsStateChangedEvent { tlvReader.enterStructure(tlvTag) val alarmsActive = tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_ACTIVE)) - val alarmsSuppressed = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) - } else { - Optional.empty() - } - + val alarmsSuppressed = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return BooleanStateConfigurationClusterAlarmsStateChangedEvent(alarmsActive, alarmsSuppressed) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt index 750d449968ba98..d29696d04cc3bf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateConfigurationClusterSensorFaultEvent( - val sensorFault: UShort -) { +class BooleanStateConfigurationClusterSensorFaultEvent(val sensorFault: UShort) { override fun toString(): String = buildString { append("BooleanStateConfigurationClusterSensorFaultEvent {\n") append("\tsensorFault : $sensorFault\n") @@ -44,10 +40,13 @@ class BooleanStateConfigurationClusterSensorFaultEvent( companion object { private const val TAG_SENSOR_FAULT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterSensorFaultEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BooleanStateConfigurationClusterSensorFaultEvent { tlvReader.enterStructure(tlvTag) val sensorFault = tlvReader.getUShort(ContextSpecificTag(TAG_SENSOR_FAULT)) - + tlvReader.exitContainer() return BooleanStateConfigurationClusterSensorFaultEvent(sensorFault) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt index 5bd65929e12bdc..2bdca2fbfb016e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationClusterReachableChangedEvent( - val reachableNewValue: Boolean -) { +class BridgedDeviceBasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") @@ -44,10 +40,13 @@ class BridgedDeviceBasicInformationClusterReachableChangedEvent( companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterReachableChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt index 67aa89e3788154..e812711dad48f2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationClusterStartUpEvent( - val softwareVersion: UInt -) { +class BridgedDeviceBasicInformationClusterStartUpEvent(val softwareVersion: UInt) { override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") @@ -44,10 +40,13 @@ class BridgedDeviceBasicInformationClusterStartUpEvent( companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterStartUpEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt index fe72fb0963a739..21b147d7ffb931 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -30,11 +29,26 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( val status: UByte, val criticality: UByte, val control: UShort, - val temperatureControl: Optional?, - val averageLoadControl: Optional?, - val dutyCycleControl: Optional?, - val powerSavingsControl: Optional?, - val heatingSourceControl: Optional? + val temperatureControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct + >?, + val averageLoadControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct + >?, + val dutyCycleControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct + >?, + val powerSavingsControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct + >?, + val heatingSourceControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct + >? ) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent {\n") @@ -65,41 +79,41 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( put(ContextSpecificTag(TAG_CONTROL), control) if (temperatureControl != null) { if (temperatureControl.isPresent) { - val opttemperatureControl = temperatureControl.get() - opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) - } + val opttemperatureControl = temperatureControl.get() + opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) } if (averageLoadControl != null) { if (averageLoadControl.isPresent) { - val optaverageLoadControl = averageLoadControl.get() - optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) - } + val optaverageLoadControl = averageLoadControl.get() + optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) } if (dutyCycleControl != null) { if (dutyCycleControl.isPresent) { - val optdutyCycleControl = dutyCycleControl.get() - optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) - } + val optdutyCycleControl = dutyCycleControl.get() + optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) } if (powerSavingsControl != null) { if (powerSavingsControl.isPresent) { - val optpowerSavingsControl = powerSavingsControl.get() - optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) - } + val optpowerSavingsControl = powerSavingsControl.get() + optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) } if (heatingSourceControl != null) { if (heatingSourceControl.isPresent) { - val optheatingSourceControl = heatingSourceControl.get() - optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) - } + val optheatingSourceControl = heatingSourceControl.get() + optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) } @@ -119,72 +133,112 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( private const val TAG_POWER_SAVINGS_CONTROL = 8 private const val TAG_HEATING_SOURCE_CONTROL = 9 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val transitionIndex = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_TRANSITION_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) - null - } + val transitionIndex = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_TRANSITION_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) + null + } val status = tlvReader.getUByte(ContextSpecificTag(TAG_STATUS)) val criticality = tlvReader.getUByte(ContextSpecificTag(TAG_CRITICALITY)) val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) - null - } - val averageLoadControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) - null - } - val dutyCycleControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) - null - } - val powerSavingsControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) - null - } - val heatingSourceControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) - null - } - + val temperatureControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterTemperatureControlStruct + .fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) + null + } + val averageLoadControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterAverageLoadControlStruct + .fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) + null + } + val dutyCycleControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterDutyCycleControlStruct + .fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) + null + } + val powerSavingsControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterPowerSavingsControlStruct + .fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) + null + } + val heatingSourceControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterHeatingSourceControlStruct + .fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent(eventID, transitionIndex, status, criticality, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) + return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( + eventID, + transitionIndex, + status, + criticality, + control, + temperatureControl, + averageLoadControl, + dutyCycleControl, + powerSavingsControl, + heatingSourceControl + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt index e05ca8e86ba704..10bda0f46af030 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,15 @@ class DeviceEnergyManagementClusterPowerAdjustEndEvent( private const val TAG_DURATION = 1 private const val TAG_ENERGY_USE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustEndEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterPowerAdjustEndEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) val energyUse = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_USE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterPowerAdjustEndEvent(cause, duration, energyUse) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt index 8d103f74e33de4..db5219f72dba0e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterResumedEvent( - val cause: UByte -) { +class DeviceEnergyManagementClusterResumedEvent(val cause: UByte) { override fun toString(): String = buildString { append("DeviceEnergyManagementClusterResumedEvent {\n") append("\tcause : $cause\n") @@ -44,10 +40,10 @@ class DeviceEnergyManagementClusterResumedEvent( companion object { private const val TAG_CAUSE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterResumedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterResumedEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterResumedEvent(cause) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt index e17f43ed147ae0..d6a5d9227ec845 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,13 +54,13 @@ class DishwasherAlarmClusterNotifyEvent( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getUInt(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getUInt(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return DishwasherAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt index a04df8246a437e..233130a2371a2e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorLockAlarmEvent( - val alarmCode: UByte -) { +class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UByte) { override fun toString(): String = buildString { append("DoorLockClusterDoorLockAlarmEvent {\n") append("\talarmCode : $alarmCode\n") @@ -44,10 +40,10 @@ class DoorLockClusterDoorLockAlarmEvent( companion object { private const val TAG_ALARM_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorLockAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorLockAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmCode = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_CODE)) - + tlvReader.exitContainer() return DoorLockClusterDoorLockAlarmEvent(alarmCode) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt index c0dd0441ac3010..92d04f6662dffe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorStateChangeEvent( - val doorState: UByte -) { +class DoorLockClusterDoorStateChangeEvent(val doorState: UByte) { override fun toString(): String = buildString { append("DoorLockClusterDoorStateChangeEvent {\n") append("\tdoorState : $doorState\n") @@ -44,10 +40,10 @@ class DoorLockClusterDoorStateChangeEvent( companion object { private const val TAG_DOOR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorStateChangeEvent { tlvReader.enterStructure(tlvTag) val doorState = tlvReader.getUByte(ContextSpecificTag(TAG_DOOR_STATE)) - + tlvReader.exitContainer() return DoorLockClusterDoorStateChangeEvent(doorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt index af031bad313f8f..0834fde8914a0d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt @@ -31,7 +31,8 @@ class DoorLockClusterLockOperationErrorEvent( val userIndex: UShort?, val fabricIndex: UByte?, val sourceNode: ULong?, - val credentials: Optional>? + val credentials: + Optional>? ) { override fun toString(): String = buildString { append("DoorLockClusterLockOperationErrorEvent {\n") @@ -68,13 +69,13 @@ class DoorLockClusterLockOperationErrorEvent( } if (credentials != null) { if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - } + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } } else { putNull(ContextSpecificTag(TAG_CREDENTIALS)) } @@ -91,49 +92,68 @@ class DoorLockClusterLockOperationErrorEvent( private const val TAG_SOURCE_NODE = 5 private const val TAG_CREDENTIALS = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationErrorEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) val operationError = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_ERROR)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while(!tlvReader.isEndOfContainer()) { - this.add(matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationErrorEvent(lockOperationType, operationSource, operationError, userIndex, fabricIndex, sourceNode, credentials) + return DoorLockClusterLockOperationErrorEvent( + lockOperationType, + operationSource, + operationError, + userIndex, + fabricIndex, + sourceNode, + credentials + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt index d47734e612adc8..c063f08d6d1e64 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt @@ -30,7 +30,8 @@ class DoorLockClusterLockOperationEvent( val userIndex: UShort?, val fabricIndex: UByte?, val sourceNode: ULong?, - val credentials: Optional>? + val credentials: + Optional>? ) { override fun toString(): String = buildString { append("DoorLockClusterLockOperationEvent {\n") @@ -65,13 +66,13 @@ class DoorLockClusterLockOperationEvent( } if (credentials != null) { if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - } + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } } else { putNull(ContextSpecificTag(TAG_CREDENTIALS)) } @@ -87,48 +88,66 @@ class DoorLockClusterLockOperationEvent( private const val TAG_SOURCE_NODE = 4 private const val TAG_CREDENTIALS = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while(!tlvReader.isEndOfContainer()) { - this.add(matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationEvent(lockOperationType, operationSource, userIndex, fabricIndex, sourceNode, credentials) + return DoorLockClusterLockOperationEvent( + lockOperationType, + operationSource, + userIndex, + fabricIndex, + sourceNode, + credentials + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt index bb39257e80cd71..3d3cd635977b85 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -84,39 +82,51 @@ class DoorLockClusterLockUserChangeEvent( private const val TAG_SOURCE_NODE = 5 private const val TAG_DATA_INDEX = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockUserChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockUserChangeEvent { tlvReader.enterStructure(tlvTag) val lockDataType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_DATA_TYPE)) val dataOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_DATA_OPERATION_TYPE)) val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val dataIndex = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_DATA_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) - null - } - + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val dataIndex = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_DATA_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockUserChangeEvent(lockDataType, dataOperationType, operationSource, userIndex, fabricIndex, sourceNode, dataIndex) + return DoorLockClusterLockUserChangeEvent( + lockDataType, + dataOperationType, + operationSource, + userIndex, + fabricIndex, + sourceNode, + dataIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt index 8fecbdd04a6da1..2533881132950b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt @@ -18,15 +18,20 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( - val energyImported: Optional, - val energyExported: Optional + val energyImported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > ) { override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent {\n") @@ -54,22 +59,38 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) - } else { - Optional.empty() - } - val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) - } else { - Optional.empty() - } - + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent(energyImported, energyExported) + return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + energyImported, + energyExported + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt index 65f3e9e1dc1ba1..17194fbe3f7d84 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt @@ -18,15 +18,20 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( - val energyImported: Optional, - val energyExported: Optional + val energyImported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > ) { override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent {\n") @@ -54,22 +59,38 @@ class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) - } else { - Optional.empty() - } - val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) - } else { - Optional.empty() - } - + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent(energyImported, energyExported) + return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + energyImported, + energyExported + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt index 78baf664f250c1..1618b5cc9ac5a9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -25,7 +24,8 @@ import matter.tlv.TlvReader import matter.tlv.TlvWriter class ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent( - val ranges: List + val ranges: + List ) { override fun toString(): String = buildString { append("ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent {\n") @@ -48,16 +48,26 @@ class ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent( companion object { private const val TAG_RANGES = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent { tlvReader.enterStructure(tlvTag) - val ranges = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RANGES)) - while(!tlvReader.isEndOfContainer()) { - this.add(matter.controller.cluster.structs.ElectricalPowerMeasurementClusterMeasurementRangeStruct.fromTlv(AnonymousTag, tlvReader)) + val ranges = + buildList< + matter.controller.cluster.structs.ElectricalPowerMeasurementClusterMeasurementRangeStruct + > { + tlvReader.enterArray(ContextSpecificTag(TAG_RANGES)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs + .ElectricalPowerMeasurementClusterMeasurementRangeStruct + .fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return ElectricalPowerMeasurementClusterMeasurementPeriodRangesEvent(ranges) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt index 6cc387e2e019e1..a0770e7e82af07 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterEVConnectedEvent( - val sessionID: UInt -) { +class EnergyEvseClusterEVConnectedEvent(val sessionID: UInt) { override fun toString(): String = buildString { append("EnergyEvseClusterEVConnectedEvent {\n") append("\tsessionID : $sessionID\n") @@ -44,10 +40,10 @@ class EnergyEvseClusterEVConnectedEvent( companion object { private const val TAG_SESSION_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVConnectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVConnectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - + tlvReader.exitContainer() return EnergyEvseClusterEVConnectedEvent(sessionID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt index ac7c61d1a78738..673441a49f6265 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -63,21 +62,28 @@ class EnergyEvseClusterEVNotDetectedEvent( private const val TAG_SESSION_ENERGY_CHARGED = 3 private const val TAG_SESSION_ENERGY_DISCHARGED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVNotDetectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVNotDetectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val sessionDuration = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_DURATION)) val sessionEnergyCharged = tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED)) - val sessionEnergyDischarged = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) - } else { - Optional.empty() - } - + val sessionEnergyDischarged = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterEVNotDetectedEvent(sessionID, state, sessionDuration, sessionEnergyCharged, sessionEnergyDischarged) + return EnergyEvseClusterEVNotDetectedEvent( + sessionID, + state, + sessionDuration, + sessionEnergyCharged, + sessionEnergyDischarged + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt index 5a121c64f1fb70..0cd20e3e47ade3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,12 @@ class EnergyEvseClusterEnergyTransferStartedEvent( private const val TAG_STATE = 1 private const val TAG_MAXIMUM_CURRENT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStartedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStartedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val maximumCurrent = tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_CURRENT)) - + tlvReader.exitContainer() return EnergyEvseClusterEnergyTransferStartedEvent(sessionID, state, maximumCurrent) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt index 01b19535348c67..093f687fb16662 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,16 +54,21 @@ class EnergyEvseClusterEnergyTransferStoppedEvent( private const val TAG_REASON = 2 private const val TAG_ENERGY_TRANSFERRED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStoppedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStoppedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val reason = tlvReader.getUByte(ContextSpecificTag(TAG_REASON)) val energyTransferred = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_TRANSFERRED)) - + tlvReader.exitContainer() - return EnergyEvseClusterEnergyTransferStoppedEvent(sessionID, state, reason, energyTransferred) + return EnergyEvseClusterEnergyTransferStoppedEvent( + sessionID, + state, + reason, + energyTransferred + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt index e49931cd4b55b8..2167c1fca408eb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,21 +58,29 @@ class EnergyEvseClusterFaultEvent( private const val TAG_FAULT_STATE_PREVIOUS_STATE = 2 private const val TAG_FAULT_STATE_CURRENT_STATE = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterFaultEvent { tlvReader.enterStructure(tlvTag) - val sessionID = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) - null - } + val sessionID = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) + null + } val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) - val faultStatePreviousState = tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) - val faultStateCurrentState = tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) - + val faultStatePreviousState = + tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) + val faultStateCurrentState = + tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) + tlvReader.exitContainer() - return EnergyEvseClusterFaultEvent(sessionID, state, faultStatePreviousState, faultStateCurrentState) + return EnergyEvseClusterFaultEvent( + sessionID, + state, + faultStatePreviousState, + faultStateCurrentState + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt index 6db4c1a10ed59f..cf0fe503e13bd8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterRFIDEvent( - val uid: ByteArray -) { +class EnergyEvseClusterRFIDEvent(val uid: ByteArray) { override fun toString(): String = buildString { append("EnergyEvseClusterRFIDEvent {\n") append("\tuid : $uid\n") @@ -44,10 +40,10 @@ class EnergyEvseClusterRFIDEvent( companion object { private const val TAG_UID = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterRFIDEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterRFIDEvent { tlvReader.enterStructure(tlvTag) val uid = tlvReader.getByteArray(ContextSpecificTag(TAG_UID)) - + tlvReader.exitContainer() return EnergyEvseClusterRFIDEvent(uid) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt index 5d6ee591cdf22d..8d13675dece145 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsClusterBootReasonEvent( - val bootReason: UByte -) { +class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UByte) { override fun toString(): String = buildString { append("GeneralDiagnosticsClusterBootReasonEvent {\n") append("\tbootReason : $bootReason\n") @@ -44,10 +40,10 @@ class GeneralDiagnosticsClusterBootReasonEvent( companion object { private const val TAG_BOOT_REASON = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterBootReasonEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterBootReasonEvent { tlvReader.enterStructure(tlvTag) val bootReason = tlvReader.getUByte(ContextSpecificTag(TAG_BOOT_REASON)) - + tlvReader.exitContainer() return GeneralDiagnosticsClusterBootReasonEvent(bootReason) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt index 415b83a66b74ba..5b7e6cd0f947aa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,28 @@ class GeneralDiagnosticsClusterHardwareFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterHardwareFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralDiagnosticsClusterHardwareFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return GeneralDiagnosticsClusterHardwareFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt index e5ae628b6edfc1..f256dddde339d2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,28 @@ class GeneralDiagnosticsClusterNetworkFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return GeneralDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt index 9ebbfae718bb68..027949831806c8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,25 @@ class GeneralDiagnosticsClusterRadioFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterRadioFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterRadioFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return GeneralDiagnosticsClusterRadioFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt index d7b7eb6f0d01d5..3326660b5e35d0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -79,25 +78,40 @@ class MediaPlaybackClusterStateChangedEvent( private const val TAG_DATA = 7 private const val TAG_AUDIO_ADVANCE_UNMUTED = 8 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val currentState = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_STATE)) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - val sampledPosition = matter.controller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv(ContextSpecificTag(TAG_SAMPLED_POSITION), tlvReader) + val sampledPosition = + matter.controller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv( + ContextSpecificTag(TAG_SAMPLED_POSITION), + tlvReader + ) val playbackSpeed = tlvReader.getFloat(ContextSpecificTag(TAG_PLAYBACK_SPEED)) val seekRangeEnd = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_END)) val seekRangeStart = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_START)) - val data = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) - } else { - Optional.empty() - } + val data = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) + } else { + Optional.empty() + } val audioAdvanceUnmuted = tlvReader.getBoolean(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED)) - + tlvReader.exitContainer() - return MediaPlaybackClusterStateChangedEvent(currentState, startTime, duration, sampledPosition, playbackSpeed, seekRangeEnd, seekRangeStart, data, audioAdvanceUnmuted) + return MediaPlaybackClusterStateChangedEvent( + currentState, + startTime, + duration, + sampledPosition, + playbackSpeed, + seekRangeEnd, + seekRangeStart, + data, + audioAdvanceUnmuted + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessageCompleteEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessageCompleteEvent.kt index 89aad1334cb56e..4c30c4ec20bd82 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessageCompleteEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessageCompleteEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -45,17 +44,17 @@ class MessagesClusterMessageCompleteEvent( put(ContextSpecificTag(TAG_MESSAGE_I_D), messageID) if (responseID != null) { if (responseID.isPresent) { - val optresponseID = responseID.get() - put(ContextSpecificTag(TAG_RESPONSE_I_D), optresponseID) - } + val optresponseID = responseID.get() + put(ContextSpecificTag(TAG_RESPONSE_I_D), optresponseID) + } } else { putNull(ContextSpecificTag(TAG_RESPONSE_I_D)) } if (reply != null) { if (reply.isPresent) { - val optreply = reply.get() - put(ContextSpecificTag(TAG_REPLY), optreply) - } + val optreply = reply.get() + put(ContextSpecificTag(TAG_REPLY), optreply) + } } else { putNull(ContextSpecificTag(TAG_REPLY)) } @@ -74,39 +73,47 @@ class MessagesClusterMessageCompleteEvent( private const val TAG_REPLY = 2 private const val TAG_FUTURE_MESSAGES_PREFERENCE = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MessagesClusterMessageCompleteEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessageCompleteEvent { tlvReader.enterStructure(tlvTag) val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D)) - val responseID = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSE_I_D))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RESPONSE_I_D))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RESPONSE_I_D)) - null - } - val reply = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_REPLY))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_REPLY))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_REPLY)) - null - } - val futureMessagesPreference = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) - null - } - + val responseID = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSE_I_D))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RESPONSE_I_D))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RESPONSE_I_D)) + null + } + val reply = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_REPLY))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_REPLY))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_REPLY)) + null + } + val futureMessagesPreference = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FUTURE_MESSAGES_PREFERENCE)) + null + } + tlvReader.exitContainer() - return MessagesClusterMessageCompleteEvent(messageID, responseID, reply, futureMessagesPreference) + return MessagesClusterMessageCompleteEvent( + messageID, + responseID, + reply, + futureMessagesPreference + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessagePresentedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessagePresentedEvent.kt index 4e532d1e7251a9..7ca3f028ab4b99 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessagePresentedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessagePresentedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MessagesClusterMessagePresentedEvent( - val messageID: ByteArray -) { +class MessagesClusterMessagePresentedEvent(val messageID: ByteArray) { override fun toString(): String = buildString { append("MessagesClusterMessagePresentedEvent {\n") append("\tmessageID : $messageID\n") @@ -44,10 +40,10 @@ class MessagesClusterMessagePresentedEvent( companion object { private const val TAG_MESSAGE_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MessagesClusterMessagePresentedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessagePresentedEvent { tlvReader.enterStructure(tlvTag) val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D)) - + tlvReader.exitContainer() return MessagesClusterMessagePresentedEvent(messageID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessageQueuedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessageQueuedEvent.kt index abffc35c63ee9d..6292136f5419a8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessageQueuedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MessagesClusterMessageQueuedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MessagesClusterMessageQueuedEvent( - val messageID: ByteArray -) { +class MessagesClusterMessageQueuedEvent(val messageID: ByteArray) { override fun toString(): String = buildString { append("MessagesClusterMessageQueuedEvent {\n") append("\tmessageID : $messageID\n") @@ -44,10 +40,10 @@ class MessagesClusterMessageQueuedEvent( companion object { private const val TAG_MESSAGE_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MessagesClusterMessageQueuedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessageQueuedEvent { tlvReader.enterStructure(tlvTag) val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D)) - + tlvReader.exitContainer() return MessagesClusterMessageQueuedEvent(messageID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt index e5a17a96700fca..4ae90661a7b56b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -43,17 +42,17 @@ class OperationalStateClusterOperationCompletionEvent( put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (pausedTime != null) { if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } } else { putNull(ContextSpecificTag(TAG_PAUSED_TIME)) } @@ -66,33 +65,42 @@ class OperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return OperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt index 10bd2f4144b114..fc6e4797a28b46 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -44,10 +42,14 @@ class OperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = matter.controller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + matter.controller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return OperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt index 3cdebe626405a4..e3fbe9c5bf247f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,26 +62,36 @@ class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( private const val TAG_PROGRESS_PERCENT = 2 private const val TAG_PLATFORM_CODE = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val bytesDownloaded = tlvReader.getULong(ContextSpecificTag(TAG_BYTES_DOWNLOADED)) - val progressPercent = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - null - } - val platformCode = if (!tlvReader.isNull()) { - tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) - null - } - + val progressPercent = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + null + } + val platformCode = + if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent(softwareVersion, bytesDownloaded, progressPercent, platformCode) + return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( + softwareVersion, + bytesDownloaded, + progressPercent, + platformCode + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt index cacab69022c9c7..52ff425323115b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,21 +58,30 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( private const val TAG_REASON = 2 private const val TAG_TARGET_SOFTWARE_VERSION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterStateTransitionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterStateTransitionEvent { tlvReader.enterStructure(tlvTag) val previousState = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_STATE)) val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) val reason = tlvReader.getUByte(ContextSpecificTag(TAG_REASON)) - val targetSoftwareVersion = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - null - } - + val targetSoftwareVersion = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterStateTransitionEvent(previousState, newState, reason, targetSoftwareVersion) + return OtaSoftwareUpdateRequestorClusterStateTransitionEvent( + previousState, + newState, + reason, + targetSoftwareVersion + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt index 227e0915fba374..cd39219a42e3bf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,14 @@ class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent( private const val TAG_SOFTWARE_VERSION = 0 private const val TAG_PRODUCT_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val productID = tlvReader.getUShort(ContextSpecificTag(TAG_PRODUCT_I_D)) - + tlvReader.exitContainer() return OtaSoftwareUpdateRequestorClusterVersionAppliedEvent(softwareVersion, productID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt index c2f767d8be59a5..7220e0afa693d2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -43,17 +42,17 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent( put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (pausedTime != null) { if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } } else { putNull(ContextSpecificTag(TAG_PAUSED_TIME)) } @@ -66,33 +65,42 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return OvenCavityOperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt index ee5fe0b442932f..bfaa8f75b3b597 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt @@ -16,16 +16,15 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OvenCavityOperationalStateClusterOperationalErrorEvent( - val errorState: matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct + val errorState: + matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct ) { override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalErrorEvent {\n") @@ -44,10 +43,17 @@ class OvenCavityOperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationalErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return OvenCavityOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt index 6669a84bd6ec2e..8e189c26173639 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,25 @@ class PowerSourceClusterBatChargeFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatChargeFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt index 50752bc8ce3d78..7aa1a81b862fd5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,10 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeEvent( - val current: List, - val previous: List -) { +class PowerSourceClusterBatFaultChangeEvent(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeEvent {\n") append("\tcurrent : $current\n") @@ -56,23 +52,25 @@ class PowerSourceClusterBatFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt index 9f125a71de6a58..5dc6444f06cd51 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,10 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeEvent( - val current: List, - val previous: List -) { +class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeEvent {\n") append("\tcurrent : $current\n") @@ -56,23 +52,25 @@ class PowerSourceClusterWiredFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterWiredFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt index 75df72186f31ce..8bfdf23df2be69 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,13 +54,13 @@ class RefrigeratorAlarmClusterNotifyEvent( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getUInt(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getUInt(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return RefrigeratorAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt index 82db20e092df34..eaafde5a0c8c68 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -43,17 +42,17 @@ class RvcOperationalStateClusterOperationCompletionEvent( put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (pausedTime != null) { if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } } else { putNull(ContextSpecificTag(TAG_PAUSED_TIME)) } @@ -66,33 +65,42 @@ class RvcOperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return RvcOperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt index 092b9234e3b44d..7a78710f647235 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -44,10 +42,17 @@ class RvcOperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationalErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = matter.controller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + matter.controller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return RvcOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt index e6853817f212a1..5570ba7a3af4a3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SampleMeiClusterPingCountEventEvent( - val count: UInt, - val fabricIndex: UByte -) { +class SampleMeiClusterPingCountEventEvent(val count: UInt, val fabricIndex: UByte) { override fun toString(): String = buildString { append("SampleMeiClusterPingCountEventEvent {\n") append("\tcount : $count\n") @@ -48,11 +43,11 @@ class SampleMeiClusterPingCountEventEvent( private const val TAG_COUNT = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SampleMeiClusterPingCountEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { tlvReader.enterStructure(tlvTag) val count = tlvReader.getUInt(ContextSpecificTag(TAG_COUNT)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return SampleMeiClusterPingCountEventEvent(count, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt index ab23f8de4499fc..52c7a19053aacb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterCOAlarmEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterCOAlarmEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt index 3ccd697a30d045..80c6a860b1ccc0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectCOAlarmEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterInterconnectCOAlarmEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt index 3edfa2543f5b3f..2a3f3f2d05c730 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt index 42579fecbdda42..3930c40935d0ef 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterLowBatteryEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterLowBatteryEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterLowBatteryEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterLowBatteryEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterLowBatteryEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterLowBatteryEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt index 25a54c367090c2..934c42da5479a2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterSmokeAlarmEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterSmokeAlarmEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt index 5d78915d64828a..c7ac6b65eae4dc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,20 +57,22 @@ class SoftwareDiagnosticsClusterSoftwareFaultEvent( private const val TAG_NAME = 1 private const val TAG_FAULT_RECORDING = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SoftwareDiagnosticsClusterSoftwareFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterSoftwareFaultEvent { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val faultRecording = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val faultRecording = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return SoftwareDiagnosticsClusterSoftwareFaultEvent(id, name, faultRecording) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt index eef9c3864807ea..f7a74f79826494 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterInitialPressEvent( - val newPosition: UByte -) { +class SwitchClusterInitialPressEvent(val newPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterInitialPressEvent {\n") append("\tnewPosition : $newPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterInitialPressEvent( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterInitialPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterInitialPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterInitialPressEvent(newPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt index 42cd9c501135bc..bacc49c76bbc53 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterLongPressEvent( - val newPosition: UByte -) { +class SwitchClusterLongPressEvent(val newPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterLongPressEvent {\n") append("\tnewPosition : $newPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterLongPressEvent( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongPressEvent(newPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt index 8de4860fe1f299..cbd0166269542b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterLongReleaseEvent( - val previousPosition: UByte -) { +class SwitchClusterLongReleaseEvent(val previousPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterLongReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterLongReleaseEvent( companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt index 49d9b22f9b45ff..4a82b4914ea426 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,12 @@ class SwitchClusterMultiPressCompleteEvent( private const val TAG_PREVIOUS_POSITION = 0 private const val TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressCompleteEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressCompleteEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - val totalNumberOfPressesCounted = tlvReader.getUByte(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) - + val totalNumberOfPressesCounted = + tlvReader.getUByte(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressCompleteEvent(previousPosition, totalNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt index 104be8f4fb63ee..4bf6776e64f14a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,12 @@ class SwitchClusterMultiPressOngoingEvent( private const val TAG_NEW_POSITION = 0 private const val TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressOngoingEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressOngoingEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - val currentNumberOfPressesCounted = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) - + val currentNumberOfPressesCounted = + tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressOngoingEvent(newPosition, currentNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt index 156c253a485af1..c08c0e63f8b5e1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterShortReleaseEvent( - val previousPosition: UByte -) { +class SwitchClusterShortReleaseEvent(val previousPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterShortReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterShortReleaseEvent( companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterShortReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterShortReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterShortReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt index f08eaeee96a617..4aae22fb446979 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterSwitchLatchedEvent( - val newPosition: UByte -) { +class SwitchClusterSwitchLatchedEvent(val newPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterSwitchLatchedEvent {\n") append("\tnewPosition : $newPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterSwitchLatchedEvent( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterSwitchLatchedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterSwitchLatchedEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterSwitchLatchedEvent(newPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt index 86a03eb5080eba..0d56be60d4b36e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,18 +55,24 @@ class TargetNavigatorClusterTargetUpdatedEvent( private const val TAG_CURRENT_TARGET = 1 private const val TAG_DATA = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TargetNavigatorClusterTargetUpdatedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetUpdatedEvent { tlvReader.enterStructure(tlvTag) - val targetList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) - while(!tlvReader.isEndOfContainer()) { - this.add(matter.controller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val targetList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } val currentTarget = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_TARGET)) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetUpdatedEvent(targetList, currentTarget, data) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt index 823b3eb003da4a..8acbb4b6aea971 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterConnectionStatusEvent( - val connectionStatus: UByte -) { +class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UByte) { override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") @@ -44,10 +40,13 @@ class ThreadNetworkDiagnosticsClusterConnectionStatusEvent( companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUByte(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt index 01a5989a931f38..3bea74d8323077 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,28 @@ class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDirectoryClusterNetworkChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDirectoryClusterNetworkChangedEvent.kt index bfe417a1f79486..8200ee623c2362 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDirectoryClusterNetworkChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDirectoryClusterNetworkChangedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDirectoryClusterNetworkChangedEvent( - val extendedPanID: ULong -) { +class ThreadNetworkDirectoryClusterNetworkChangedEvent(val extendedPanID: ULong) { override fun toString(): String = buildString { append("ThreadNetworkDirectoryClusterNetworkChangedEvent {\n") append("\textendedPanID : $extendedPanID\n") @@ -44,10 +40,13 @@ class ThreadNetworkDirectoryClusterNetworkChangedEvent( companion object { private const val TAG_EXTENDED_PAN_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDirectoryClusterNetworkChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDirectoryClusterNetworkChangedEvent { tlvReader.enterStructure(tlvTag) val extendedPanID = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_I_D)) - + tlvReader.exitContainer() return ThreadNetworkDirectoryClusterNetworkChangedEvent(extendedPanID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt index e8870c27fe9ff6..1f92e4003e280a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterDSTStatusEvent( - val DSTOffsetActive: Boolean -) { +class TimeSynchronizationClusterDSTStatusEvent(val DSTOffsetActive: Boolean) { override fun toString(): String = buildString { append("TimeSynchronizationClusterDSTStatusEvent {\n") append("\tDSTOffsetActive : $DSTOffsetActive\n") @@ -44,10 +40,10 @@ class TimeSynchronizationClusterDSTStatusEvent( companion object { private const val TAG_D_S_T_OFFSET_ACTIVE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterDSTStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterDSTStatusEvent { tlvReader.enterStructure(tlvTag) val DSTOffsetActive = tlvReader.getBoolean(ContextSpecificTag(TAG_D_S_T_OFFSET_ACTIVE)) - + tlvReader.exitContainer() return TimeSynchronizationClusterDSTStatusEvent(DSTOffsetActive) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt index 0a12d142db0443..0ef92440535c0a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterTimeZoneStatusEvent( - val offset: Int, - val name: Optional -) { +class TimeSynchronizationClusterTimeZoneStatusEvent(val offset: Int, val name: Optional) { override fun toString(): String = buildString { append("TimeSynchronizationClusterTimeZoneStatusEvent {\n") append("\toffset : $offset\n") @@ -51,15 +47,16 @@ class TimeSynchronizationClusterTimeZoneStatusEvent( private const val TAG_OFFSET = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTimeZoneStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTimeZoneStatusEvent { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getInt(ContextSpecificTag(TAG_OFFSET)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStatusEvent(offset, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestDifferentVendorMeiEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestDifferentVendorMeiEventEvent.kt index add97526607d6d..db7bddcfeb96e1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestDifferentVendorMeiEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestDifferentVendorMeiEventEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestDifferentVendorMeiEventEvent( - val arg1: UByte -) { +class UnitTestingClusterTestDifferentVendorMeiEventEvent(val arg1: UByte) { override fun toString(): String = buildString { append("UnitTestingClusterTestDifferentVendorMeiEventEvent {\n") append("\targ1 : $arg1\n") @@ -44,10 +40,13 @@ class UnitTestingClusterTestDifferentVendorMeiEventEvent( companion object { private const val TAG_ARG1 = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestDifferentVendorMeiEventEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): UnitTestingClusterTestDifferentVendorMeiEventEvent { tlvReader.enterStructure(tlvTag) val arg1 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG1)) - + tlvReader.exitContainer() return UnitTestingClusterTestDifferentVendorMeiEventEvent(arg1) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt index 2294e08b8377db..b95fb1a6114b7f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -72,27 +71,38 @@ class UnitTestingClusterTestEventEvent( private const val TAG_ARG5 = 5 private const val TAG_ARG6 = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestEventEvent { tlvReader.enterStructure(tlvTag) val arg1 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG1)) val arg2 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG2)) val arg3 = tlvReader.getBoolean(ContextSpecificTag(TAG_ARG3)) - val arg4 = matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_ARG4), tlvReader) - val arg5 = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) - while(!tlvReader.isEndOfContainer()) { - this.add(matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + val arg4 = + matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_ARG4), + tlvReader + ) + val arg5 = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val arg6 = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val arg6 = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return UnitTestingClusterTestEventEvent(arg1, arg2, arg3, arg4, arg5, arg6) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt index a52b06cd5cbd96..b0ac8683c99209 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestFabricScopedEventEvent( - val fabricIndex: UByte -) { +class UnitTestingClusterTestFabricScopedEventEvent(val fabricIndex: UByte) { override fun toString(): String = buildString { append("UnitTestingClusterTestFabricScopedEventEvent {\n") append("\tfabricIndex : $fabricIndex\n") @@ -44,10 +40,10 @@ class UnitTestingClusterTestFabricScopedEventEvent( companion object { private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestFabricScopedEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScopedEventEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return UnitTestingClusterTestFabricScopedEventEvent(fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt index a740d0e35331fe..6c207e60058efa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlClusterValveFaultEvent( - val valveFault: UShort -) { +class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UShort) { override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveFaultEvent {\n") append("\tvalveFault : $valveFault\n") @@ -44,10 +40,13 @@ class ValveConfigurationAndControlClusterValveFaultEvent( companion object { private const val TAG_VALVE_FAULT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveFaultEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ValveConfigurationAndControlClusterValveFaultEvent { tlvReader.enterStructure(tlvTag) val valveFault = tlvReader.getUShort(ContextSpecificTag(TAG_VALVE_FAULT)) - + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveFaultEvent(valveFault) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt index 2331135586801c..c12b94b0e375bf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,15 +50,19 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent( private const val TAG_VALVE_STATE = 0 private const val TAG_VALVE_LEVEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveStateChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ValveConfigurationAndControlClusterValveStateChangedEvent { tlvReader.enterStructure(tlvTag) val valveState = tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_STATE)) - val valveLevel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_LEVEL))) - } else { - Optional.empty() - } - + val valveLevel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_LEVEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveStateChangedEvent(valveState, valveLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt index fddf6cdad7a8a6..677577429c1796 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,15 @@ class WiFiNetworkDiagnosticsClusterAssociationFailureEvent( private const val TAG_ASSOCIATION_FAILURE_CAUSE = 0 private const val TAG_STATUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterAssociationFailureEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterAssociationFailureEvent { tlvReader.enterStructure(tlvTag) - val associationFailureCause = tlvReader.getUByte(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) + val associationFailureCause = + tlvReader.getUByte(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) val status = tlvReader.getUShort(ContextSpecificTag(TAG_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterAssociationFailureEvent(associationFailureCause, status) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt index 0e668adcf859dd..af8d2c296abe2e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterConnectionStatusEvent( - val connectionStatus: UByte -) { +class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UByte) { override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") @@ -44,10 +40,13 @@ class WiFiNetworkDiagnosticsClusterConnectionStatusEvent( companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUByte(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt index 40a4bf1d3cc947..a61a9742ede95a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterDisconnectionEvent( - val reasonCode: UShort -) { +class WiFiNetworkDiagnosticsClusterDisconnectionEvent(val reasonCode: UShort) { override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterDisconnectionEvent {\n") append("\treasonCode : $reasonCode\n") @@ -44,10 +40,13 @@ class WiFiNetworkDiagnosticsClusterDisconnectionEvent( companion object { private const val TAG_REASON_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterDisconnectionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterDisconnectionEvent { tlvReader.enterStructure(tlvTag) val reasonCode = tlvReader.getUShort(ContextSpecificTag(TAG_REASON_CODE)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterDisconnectionEvent(reasonCode) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt index bd703215de0a5b..f177b65134c50c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -48,19 +47,19 @@ class AccessControlClusterAccessControlEntryStruct( put(ContextSpecificTag(TAG_AUTH_MODE), authMode) if (subjects != null) { startArray(ContextSpecificTag(TAG_SUBJECTS)) - for (item in subjects.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in subjects.iterator()) { + put(AnonymousTag, item) + } + endArray() } else { putNull(ContextSpecificTag(TAG_SUBJECTS)) } if (targets != null) { startArray(ContextSpecificTag(TAG_TARGETS)) - for (item in targets.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in targets.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } else { putNull(ContextSpecificTag(TAG_TARGETS)) } @@ -80,35 +79,43 @@ class AccessControlClusterAccessControlEntryStruct( tlvReader.enterStructure(tlvTag) val privilege = tlvReader.getUByte(ContextSpecificTag(TAG_PRIVILEGE)) val authMode = tlvReader.getUByte(ContextSpecificTag(TAG_AUTH_MODE)) - val subjects = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getULong(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) - null - } - val targets = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) - null - } + val subjects = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getULong(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) + null + } + val targets = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryStruct(privilege, authMode, subjects, targets, fabricIndex) + return AccessControlClusterAccessControlEntryStruct( + privilege, + authMode, + subjects, + targets, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt index 8ffb7a94a61ed1..4427b4a4671abe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,14 @@ class AccessControlClusterAccessControlExtensionStruct( private const val TAG_DATA = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlExtensionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlExtensionStruct { tlvReader.enterStructure(tlvTag) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return AccessControlClusterAccessControlExtensionStruct(data, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt index dc275d27e5f803..c0197f9d712c79 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -66,25 +64,28 @@ class AccessControlClusterAccessControlTargetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlTargetStruct { tlvReader.enterStructure(tlvTag) - val cluster = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) - null - } - val endpoint = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) - null - } - val deviceType = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_TYPE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) - null - } - + val cluster = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) + null + } + val endpoint = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) + null + } + val deviceType = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_TYPE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) + null + } + tlvReader.exitContainer() return AccessControlClusterAccessControlTargetStruct(cluster, endpoint, deviceType) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt index 8b13dbce2d91cf..73476687b0478e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,10 +70,17 @@ class ActionsClusterActionStruct( val endpointListID = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val supportedCommands = tlvReader.getUShort(ContextSpecificTag(TAG_SUPPORTED_COMMANDS)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) - + tlvReader.exitContainer() - return ActionsClusterActionStruct(actionID, name, type, endpointListID, supportedCommands, state) + return ActionsClusterActionStruct( + actionID, + name, + type, + endpointListID, + supportedCommands, + state + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt index 33c1848cd172d3..94dda8930854be 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -65,14 +64,15 @@ class ActionsClusterEndpointListStruct( val endpointListID = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) - val endpoints = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val endpoints = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ActionsClusterEndpointListStruct(endpointListID, name, type, endpoints) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt index c43c172f39ad4a..afa7a17f5647c8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,14 +46,22 @@ class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) - val productIdentifierType = tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierType = + tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) + val productIdentifierValue = + tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) + return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( + productIdentifierType, + productIdentifierValue + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt index e9566b36b3ab97..2172fbb67b699f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,7 +50,7 @@ class ApplicationBasicClusterApplicationStruct( tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUShort(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationBasicClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt index eeca3b79254426..9329e2a02a429b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -53,13 +52,18 @@ class ApplicationLauncherClusterApplicationEPStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationLauncherClusterApplicationEPStruct { tlvReader.enterStructure(tlvTag) - val application = ApplicationLauncherClusterApplicationStruct.fromTlv(ContextSpecificTag(TAG_APPLICATION), tlvReader) - val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - + val application = + ApplicationLauncherClusterApplicationStruct.fromTlv( + ContextSpecificTag(TAG_APPLICATION), + tlvReader + ) + val endpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationEPStruct(application, endpoint) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt index 4ca21f08b941b7..823ca308e47dde 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,7 +50,7 @@ class ApplicationLauncherClusterApplicationStruct( tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUShort(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt index 2a48b0b450bf4a..03f59264fc2501 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class AudioOutputClusterOutputInfoStruct( val index = tlvReader.getUByte(ContextSpecificTag(TAG_INDEX)) val outputType = tlvReader.getUByte(ContextSpecificTag(TAG_OUTPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return AudioOutputClusterOutputInfoStruct(index, outputType, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt index aa977b5fdb8578..a25807e0c8d155 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,12 +48,17 @@ class BasicInformationClusterCapabilityMinimaStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterCapabilityMinimaStruct { tlvReader.enterStructure(tlvTag) - val caseSessionsPerFabric = tlvReader.getUShort(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) - val subscriptionsPerFabric = tlvReader.getUShort(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) - + val caseSessionsPerFabric = + tlvReader.getUShort(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) + val subscriptionsPerFabric = + tlvReader.getUShort(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) + tlvReader.exitContainer() - return BasicInformationClusterCapabilityMinimaStruct(caseSessionsPerFabric, subscriptionsPerFabric) + return BasicInformationClusterCapabilityMinimaStruct( + caseSessionsPerFabric, + subscriptionsPerFabric + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt index d5cc1315e520cd..56583564b0c687 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterProductAppearanceStruct( - val finish: UByte, - val primaryColor: UByte? -) { +class BasicInformationClusterProductAppearanceStruct(val finish: UByte, val primaryColor: UByte?) { override fun toString(): String = buildString { append("BasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") @@ -55,13 +50,14 @@ class BasicInformationClusterProductAppearanceStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUByte(ContextSpecificTag(TAG_FINISH)) - val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt index 1a382bd10ab5a0..84be9b6dd69995 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -74,28 +73,32 @@ class BindingClusterTargetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BindingClusterTargetStruct { tlvReader.enterStructure(tlvTag) - val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - val group = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_GROUP))) - } else { - Optional.empty() - } - val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - val cluster = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER))) - } else { - Optional.empty() - } + val node = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + val group = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_GROUP))) + } else { + Optional.empty() + } + val endpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + val cluster = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BindingClusterTargetStruct(node, group, endpoint, cluster, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt index 9e9eabc793ef94..94e9b134c06b09 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,16 +50,20 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct( private const val TAG_FINISH = 0 private const val TAG_PRIMARY_COLOR = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BridgedDeviceBasicInformationClusterProductAppearanceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUByte(ContextSpecificTag(TAG_FINISH)) - val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt index 9c504e9f434b18..cd2eacc749cb0d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterAdditionalInfoStruct( - val name: String, - val value: String -) { +class ChannelClusterAdditionalInfoStruct(val name: String, val value: String) { override fun toString(): String = buildString { append("ChannelClusterAdditionalInfoStruct {\n") append("\tname : $name\n") @@ -52,7 +47,7 @@ class ChannelClusterAdditionalInfoStruct( tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ChannelClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt index 914bcad0e6cc7f..627dcdcbefa16f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -87,35 +86,48 @@ class ChannelClusterChannelInfoStruct( tlvReader.enterStructure(tlvTag) val majorNumber = tlvReader.getUShort(ContextSpecificTag(TAG_MAJOR_NUMBER)) val minorNumber = tlvReader.getUShort(ContextSpecificTag(TAG_MINOR_NUMBER)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val callSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) - } else { - Optional.empty() - } - val affiliateCallSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) - } else { - Optional.empty() - } - val identifier = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) - } else { - Optional.empty() - } - val type = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TYPE))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val callSign = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) + } else { + Optional.empty() + } + val affiliateCallSign = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) + } else { + Optional.empty() + } + val identifier = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) + } else { + Optional.empty() + } + val type = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TYPE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterChannelInfoStruct(majorNumber, minorNumber, name, callSign, affiliateCallSign, identifier, type) + return ChannelClusterChannelInfoStruct( + majorNumber, + minorNumber, + name, + callSign, + affiliateCallSign, + identifier, + type + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt index f3b7c7d5f51755..3d190489316d4a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -40,17 +39,17 @@ class ChannelClusterChannelPagingStruct( startStructure(tlvTag) if (previousToken != null) { if (previousToken.isPresent) { - val optpreviousToken = previousToken.get() - optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) - } + val optpreviousToken = previousToken.get() + optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) + } } else { putNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) } if (nextToken != null) { if (nextToken.isPresent) { - val optnextToken = nextToken.get() - optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) - } + val optnextToken = nextToken.get() + optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) + } } else { putNull(ContextSpecificTag(TAG_NEXT_TOKEN)) } @@ -64,27 +63,36 @@ class ChannelClusterChannelPagingStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterChannelPagingStruct { tlvReader.enterStructure(tlvTag) - val previousToken = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { - Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) - null - } - val nextToken = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { - Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) - null - } - + val previousToken = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { + Optional.of( + ChannelClusterPageTokenStruct.fromTlv( + ContextSpecificTag(TAG_PREVIOUS_TOKEN), + tlvReader + ) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) + null + } + val nextToken = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { + Optional.of( + ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) + null + } + tlvReader.exitContainer() return ChannelClusterChannelPagingStruct(previousToken, nextToken) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt index 21eb682b010a20..e8e25f3fe16a7e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -65,18 +64,20 @@ class ChannelClusterLineupInfoStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterLineupInfoStruct { tlvReader.enterStructure(tlvTag) val operatorName = tlvReader.getString(ContextSpecificTag(TAG_OPERATOR_NAME)) - val lineupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) - } else { - Optional.empty() - } - val postalCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) - } else { - Optional.empty() - } + val lineupName = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) + } else { + Optional.empty() + } + val postalCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) + } else { + Optional.empty() + } val lineupInfoType = tlvReader.getUByte(ContextSpecificTag(TAG_LINEUP_INFO_TYPE)) - + tlvReader.exitContainer() return ChannelClusterLineupInfoStruct(operatorName, lineupName, postalCode, lineupInfoType) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt index 963a7c2beb5ffa..e9712955df7799 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -63,22 +62,25 @@ class ChannelClusterPageTokenStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterPageTokenStruct { tlvReader.enterStructure(tlvTag) - val limit = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_LIMIT))) - } else { - Optional.empty() - } - val after = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) - } else { - Optional.empty() - } - val before = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) - } else { - Optional.empty() - } - + val limit = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_LIMIT))) + } else { + Optional.empty() + } + val after = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) + } else { + Optional.empty() + } + val before = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterPageTokenStruct(limit, after, before) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt index 54568f0b775970..45b0a22100ef25 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterProgramCastStruct( - val name: String, - val role: String -) { +class ChannelClusterProgramCastStruct(val name: String, val role: String) { override fun toString(): String = buildString { append("ChannelClusterProgramCastStruct {\n") append("\tname : $name\n") @@ -52,7 +47,7 @@ class ChannelClusterProgramCastStruct( tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val role = tlvReader.getString(ContextSpecificTag(TAG_ROLE)) - + tlvReader.exitContainer() return ChannelClusterProgramCastStruct(name, role) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt index 3ffaea537244dc..6e89f24cd39e25 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterProgramCategoryStruct( - val category: String, - val subCategory: Optional -) { +class ChannelClusterProgramCategoryStruct(val category: String, val subCategory: Optional) { override fun toString(): String = buildString { append("ChannelClusterProgramCategoryStruct {\n") append("\tcategory : $category\n") @@ -54,12 +50,13 @@ class ChannelClusterProgramCategoryStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramCategoryStruct { tlvReader.enterStructure(tlvTag) val category = tlvReader.getString(ContextSpecificTag(TAG_CATEGORY)) - val subCategory = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) - } else { - Optional.empty() - } - + val subCategory = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterProgramCategoryStruct(category, subCategory) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt index 327c6622543aff..f40e13d0894446 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt @@ -88,18 +88,18 @@ class ChannelClusterProgramStruct( if (audioLanguages.isPresent) { val optaudioLanguages = audioLanguages.get() startArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - for (item in optaudioLanguages.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optaudioLanguages.iterator()) { + put(AnonymousTag, item) + } + endArray() } if (ratings.isPresent) { val optratings = ratings.get() startArray(ContextSpecificTag(TAG_RATINGS)) - for (item in optratings.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optratings.iterator()) { + put(AnonymousTag, item) + } + endArray() } if (thumbnailUrl.isPresent) { val optthumbnailUrl = thumbnailUrl.get() @@ -127,35 +127,35 @@ class ChannelClusterProgramStruct( } if (seriesInfo != null) { if (seriesInfo.isPresent) { - val optseriesInfo = seriesInfo.get() - optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) - } + val optseriesInfo = seriesInfo.get() + optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) + } } else { putNull(ContextSpecificTag(TAG_SERIES_INFO)) } if (categoryList.isPresent) { val optcategoryList = categoryList.get() startArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - for (item in optcategoryList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optcategoryList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } if (castList.isPresent) { val optcastList = castList.get() startArray(ContextSpecificTag(TAG_CAST_LIST)) - for (item in optcastList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optcastList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } if (externalIDList.isPresent) { val optexternalIDList = externalIDList.get() startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -185,119 +185,166 @@ class ChannelClusterProgramStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramStruct { tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER)) - val channel = ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) + val channel = + ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) val startTime = tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getUInt(ContextSpecificTag(TAG_END_TIME)) val title = tlvReader.getString(ContextSpecificTag(TAG_TITLE)) - val subtitle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) - } else { - Optional.empty() - } - val description = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) - } else { - Optional.empty() - } - val audioLanguages = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val ratings = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val thumbnailUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) - } else { - Optional.empty() - } - val posterArtUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) - } else { - Optional.empty() - } - val dvbiUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) - } else { - Optional.empty() - } - val releaseDate = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) - } else { - Optional.empty() - } - val parentalGuidanceText = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) - } else { - Optional.empty() - } - val recordingFlag = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RECORDING_FLAG))) - } else { - Optional.empty() - } - val seriesInfo = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { - Optional.of(ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) - null - } - val categoryList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val castList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val subtitle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) + } else { + Optional.empty() + } + val description = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) + } else { + Optional.empty() + } + val audioLanguages = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val ratings = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val thumbnailUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) + } else { + Optional.empty() + } + val posterArtUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) + } else { + Optional.empty() + } + val dvbiUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) + } else { + Optional.empty() + } + val releaseDate = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) + } else { + Optional.empty() + } + val parentalGuidanceText = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) + } else { + Optional.empty() + } + val recordingFlag = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RECORDING_FLAG))) + } else { + Optional.empty() + } + val seriesInfo = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { + Optional.of( + ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) + null + } + val categoryList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val castList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val externalIDList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterProgramStruct(identifier, channel, startTime, endTime, title, subtitle, description, audioLanguages, ratings, thumbnailUrl, posterArtUrl, dvbiUrl, releaseDate, parentalGuidanceText, recordingFlag, seriesInfo, categoryList, castList, externalIDList) + return ChannelClusterProgramStruct( + identifier, + channel, + startTime, + endTime, + title, + subtitle, + description, + audioLanguages, + ratings, + thumbnailUrl, + posterArtUrl, + dvbiUrl, + releaseDate, + parentalGuidanceText, + recordingFlag, + seriesInfo, + categoryList, + castList, + externalIDList + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt index c0445d55460703..9e3928a48de8a5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterSeriesInfoStruct( - val season: String, - val episode: String -) { +class ChannelClusterSeriesInfoStruct(val season: String, val episode: String) { override fun toString(): String = buildString { append("ChannelClusterSeriesInfoStruct {\n") append("\tseason : $season\n") @@ -52,7 +47,7 @@ class ChannelClusterSeriesInfoStruct( tlvReader.enterStructure(tlvTag) val season = tlvReader.getString(ContextSpecificTag(TAG_SEASON)) val episode = tlvReader.getString(ContextSpecificTag(TAG_EPISODE)) - + tlvReader.exitContainer() return ChannelClusterSeriesInfoStruct(season, episode) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt index fe5058eb533a87..c47570f255caaa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,12 +53,13 @@ class ContentControlClusterRatingNameStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentControlClusterRatingNameStruct { tlvReader.enterStructure(tlvTag) val ratingName = tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME)) - val ratingNameDesc = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) - } else { - Optional.empty() - } - + val ratingNameDesc = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentControlClusterRatingNameStruct(ratingName, ratingNameDesc) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt index 504997933652c9..af51becfe86381 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterAdditionalInfoStruct( - val name: String, - val value: String -) { +class ContentLauncherClusterAdditionalInfoStruct(val name: String, val value: String) { override fun toString(): String = buildString { append("ContentLauncherClusterAdditionalInfoStruct {\n") append("\tname : $name\n") @@ -52,7 +47,7 @@ class ContentLauncherClusterAdditionalInfoStruct( tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ContentLauncherClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt index e94826e1eb40d8..4470b659b2e59f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -79,38 +78,78 @@ class ContentLauncherClusterBrandingInformationStruct( private const val TAG_SPLASH = 4 private const val TAG_WATER_MARK = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterBrandingInformationStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ContentLauncherClusterBrandingInformationStruct { tlvReader.enterStructure(tlvTag) val providerName = tlvReader.getString(ContextSpecificTag(TAG_PROVIDER_NAME)) - val background = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_BACKGROUND), tlvReader)) - } else { - Optional.empty() - } - val logo = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_LOGO), tlvReader)) - } else { - Optional.empty() - } - val progressBar = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_PROGRESS_BAR), tlvReader)) - } else { - Optional.empty() - } - val splash = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_SPLASH), tlvReader)) - } else { - Optional.empty() - } - val waterMark = if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_WATER_MARK), tlvReader)) - } else { - Optional.empty() - } - + val background = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_BACKGROUND), + tlvReader + ) + ) + } else { + Optional.empty() + } + val logo = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_LOGO), + tlvReader + ) + ) + } else { + Optional.empty() + } + val progressBar = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_PROGRESS_BAR), + tlvReader + ) + ) + } else { + Optional.empty() + } + val splash = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_SPLASH), + tlvReader + ) + ) + } else { + Optional.empty() + } + val waterMark = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_WATER_MARK), + tlvReader + ) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterBrandingInformationStruct(providerName, background, logo, progressBar, splash, waterMark) + return ContentLauncherClusterBrandingInformationStruct( + providerName, + background, + logo, + progressBar, + splash, + waterMark + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt index 052e4f66723755..1fe0fc71463ee6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -50,14 +49,15 @@ class ContentLauncherClusterContentSearchStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterContentSearchStruct { tlvReader.enterStructure(tlvTag) - val parameterList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val parameterList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ContentLauncherClusterContentSearchStruct(parameterList) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt index 5870e4079531e8..f9c4eb2d6f4502 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class ContentLauncherClusterDimensionStruct( val width = tlvReader.getDouble(ContextSpecificTag(TAG_WIDTH)) val height = tlvReader.getDouble(ContextSpecificTag(TAG_HEIGHT)) val metric = tlvReader.getUByte(ContextSpecificTag(TAG_METRIC)) - + tlvReader.exitContainer() return ContentLauncherClusterDimensionStruct(width, height, metric) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt index 9b85de042f0a94..e0975b8e1c6c9f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt @@ -45,10 +45,10 @@ class ContentLauncherClusterParameterStruct( if (externalIDList.isPresent) { val optexternalIDList = externalIDList.get() startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -63,18 +63,21 @@ class ContentLauncherClusterParameterStruct( tlvReader.enterStructure(tlvTag) val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val externalIDList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterParameterStruct(type, value, externalIDList) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt index adba8615ee2d73..694f35fc4364d1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt @@ -45,10 +45,10 @@ class ContentLauncherClusterPlaybackPreferencesStruct( if (audioTracks.isPresent) { val optaudioTracks = audioTracks.get() startArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - for (item in optaudioTracks.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optaudioTracks.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -59,25 +59,39 @@ class ContentLauncherClusterPlaybackPreferencesStruct( private const val TAG_TEXT_TRACK = 1 private const val TAG_AUDIO_TRACKS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterPlaybackPreferencesStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ContentLauncherClusterPlaybackPreferencesStruct { tlvReader.enterStructure(tlvTag) val playbackPosition = tlvReader.getULong(ContextSpecificTag(TAG_PLAYBACK_POSITION)) - val textTrack = ContentLauncherClusterTrackPreferenceStruct.fromTlv(ContextSpecificTag(TAG_TEXT_TRACK), tlvReader) - val audioTracks = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val textTrack = + ContentLauncherClusterTrackPreferenceStruct.fromTlv( + ContextSpecificTag(TAG_TEXT_TRACK), + tlvReader + ) + val audioTracks = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterPlaybackPreferencesStruct(playbackPosition, textTrack, audioTracks) + return ContentLauncherClusterPlaybackPreferencesStruct( + playbackPosition, + textTrack, + audioTracks + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt index 6c0f03344a31eb..e57d04e099fb44 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -63,22 +62,27 @@ class ContentLauncherClusterStyleInformationStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterStyleInformationStruct { tlvReader.enterStructure(tlvTag) - val imageURL = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) - } else { - Optional.empty() - } - val color = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) - } else { - Optional.empty() - } - val size = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { - Optional.of(ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader)) - } else { - Optional.empty() - } - + val imageURL = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) + } else { + Optional.empty() + } + val color = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) + } else { + Optional.empty() + } + val size = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { + Optional.of( + ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterStyleInformationStruct(imageURL, color, size) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt index 47dadc45c6f0b3..74c3088d135bcc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt @@ -44,10 +44,10 @@ class ContentLauncherClusterTrackPreferenceStruct( if (characteristics.isPresent) { val optcharacteristics = characteristics.get() startArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - for (item in optcharacteristics.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optcharacteristics.iterator()) { + put(AnonymousTag, item) + } + endArray() } put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX), audioOutputIndex) endStructure() @@ -62,22 +62,29 @@ class ContentLauncherClusterTrackPreferenceStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterTrackPreferenceStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val characteristics = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } + val characteristics = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } val audioOutputIndex = tlvReader.getUByte(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX)) - + tlvReader.exitContainer() - return ContentLauncherClusterTrackPreferenceStruct(languageCode, characteristics, audioOutputIndex) + return ContentLauncherClusterTrackPreferenceStruct( + languageCode, + characteristics, + audioOutputIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt index 5a055dd4270923..4473bd4520dcd2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterAverageLoadControlStruct( - val loadAdjustment: Byte -) { +class DemandResponseLoadControlClusterAverageLoadControlStruct(val loadAdjustment: Byte) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterAverageLoadControlStruct {\n") append("\tloadAdjustment : $loadAdjustment\n") @@ -44,10 +40,13 @@ class DemandResponseLoadControlClusterAverageLoadControlStruct( companion object { private const val TAG_LOAD_ADJUSTMENT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterAverageLoadControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterAverageLoadControlStruct { tlvReader.enterStructure(tlvTag) val loadAdjustment = tlvReader.getByte(ContextSpecificTag(TAG_LOAD_ADJUSTMENT)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterAverageLoadControlStruct(loadAdjustment) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt index 9573a4e3ff11fa..7e53d779dda4e3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterDutyCycleControlStruct( - val dutyCycle: UByte -) { +class DemandResponseLoadControlClusterDutyCycleControlStruct(val dutyCycle: UByte) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterDutyCycleControlStruct {\n") append("\tdutyCycle : $dutyCycle\n") @@ -44,10 +40,13 @@ class DemandResponseLoadControlClusterDutyCycleControlStruct( companion object { private const val TAG_DUTY_CYCLE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterDutyCycleControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterDutyCycleControlStruct { tlvReader.enterStructure(tlvTag) val dutyCycle = tlvReader.getUByte(ContextSpecificTag(TAG_DUTY_CYCLE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterDutyCycleControlStruct(dutyCycle) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt index ed90e36f3a637e..aeae2026e12db2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterHeatingSourceControlStruct( - val heatingSource: UByte -) { +class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSource: UByte) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterHeatingSourceControlStruct {\n") append("\theatingSource : $heatingSource\n") @@ -44,10 +40,13 @@ class DemandResponseLoadControlClusterHeatingSourceControlStruct( companion object { private const val TAG_HEATING_SOURCE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterHeatingSourceControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterHeatingSourceControlStruct { tlvReader.enterStructure(tlvTag) val heatingSource = tlvReader.getUByte(ContextSpecificTag(TAG_HEATING_SOURCE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterHeatingSourceControlStruct(heatingSource) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt index f0a1f42885e734..e8f15e8cdb0064 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt @@ -87,40 +87,61 @@ class DemandResponseLoadControlClusterLoadControlEventStruct( private const val TAG_START_TIME = 6 private const val TAG_TRANSITIONS = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterLoadControlEventStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventStruct { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val programID = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) - null - } + val programID = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) + null + } val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) val deviceClass = tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_CLASS)) - val enrollmentGroup = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) - } else { - Optional.empty() - } + val enrollmentGroup = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) + } else { + Optional.empty() + } val criticality = tlvReader.getUByte(ContextSpecificTag(TAG_CRITICALITY)) - val startTime = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val transitions = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val startTime = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) + null + } + val transitions = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStruct(eventID, programID, control, deviceClass, enrollmentGroup, criticality, startTime, transitions) + return DemandResponseLoadControlClusterLoadControlEventStruct( + eventID, + programID, + control, + deviceClass, + enrollmentGroup, + criticality, + startTime, + transitions + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt index 8b11bb21f1b0a0..1bad4e81db4b9a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -83,39 +82,80 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( private const val TAG_POWER_SAVINGS_CONTROL = 5 private const val TAG_HEATING_SOURCE_CONTROL = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { tlvReader.enterStructure(tlvTag) val duration = tlvReader.getUShort(ContextSpecificTag(TAG_DURATION)) val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val averageLoadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val dutyCycleControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val powerSavingsControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val heatingSourceControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - + val temperatureControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv( + ContextSpecificTag(TAG_TEMPERATURE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val averageLoadControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv( + ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val dutyCycleControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv( + ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val powerSavingsControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv( + ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val heatingSourceControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv( + ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventTransitionStruct(duration, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) + return DemandResponseLoadControlClusterLoadControlEventTransitionStruct( + duration, + control, + temperatureControl, + averageLoadControl, + dutyCycleControl, + powerSavingsControl, + heatingSourceControl + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt index b40fac86f3abf0..d3aea5654d479b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,32 +70,44 @@ class DemandResponseLoadControlClusterLoadControlProgramStruct( private const val TAG_RANDOM_START_MINUTES = 3 private const val TAG_RANDOM_DURATION_MINUTES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterLoadControlProgramStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlProgramStruct { tlvReader.enterStructure(tlvTag) val programID = tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - val enrollmentGroup = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - null - } - val randomStartMinutes = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - null - } - val randomDurationMinutes = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - null - } - + val enrollmentGroup = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + null + } + val randomStartMinutes = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + null + } + val randomDurationMinutes = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlProgramStruct(programID, name, enrollmentGroup, randomStartMinutes, randomDurationMinutes) + return DemandResponseLoadControlClusterLoadControlProgramStruct( + programID, + name, + enrollmentGroup, + randomStartMinutes, + randomDurationMinutes + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt index 08d7bc21262e2e..485257eb7dbf1c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterPowerSavingsControlStruct( - val powerSavings: UByte -) { +class DemandResponseLoadControlClusterPowerSavingsControlStruct(val powerSavings: UByte) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterPowerSavingsControlStruct {\n") append("\tpowerSavings : $powerSavings\n") @@ -44,10 +40,13 @@ class DemandResponseLoadControlClusterPowerSavingsControlStruct( companion object { private const val TAG_POWER_SAVINGS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterPowerSavingsControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterPowerSavingsControlStruct { tlvReader.enterStructure(tlvTag) val powerSavings = tlvReader.getUByte(ContextSpecificTag(TAG_POWER_SAVINGS)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterPowerSavingsControlStruct(powerSavings) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt index d6bd0cd2524906..635b2541684b05 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -44,33 +43,33 @@ class DemandResponseLoadControlClusterTemperatureControlStruct( startStructure(tlvTag) if (coolingTempOffset != null) { if (coolingTempOffset.isPresent) { - val optcoolingTempOffset = coolingTempOffset.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) - } + val optcoolingTempOffset = coolingTempOffset.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) + } } else { putNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) } if (heatingtTempOffset != null) { if (heatingtTempOffset.isPresent) { - val optheatingtTempOffset = heatingtTempOffset.get() - put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) - } + val optheatingtTempOffset = heatingtTempOffset.get() + put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) + } } else { putNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) } if (coolingTempSetpoint != null) { if (coolingTempSetpoint.isPresent) { - val optcoolingTempSetpoint = coolingTempSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) - } + val optcoolingTempSetpoint = coolingTempSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) + } } else { putNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) } if (heatingTempSetpoint != null) { if (heatingTempSetpoint.isPresent) { - val optheatingTempSetpoint = heatingTempSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) - } + val optheatingTempSetpoint = heatingTempSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) + } } else { putNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) } @@ -84,52 +83,64 @@ class DemandResponseLoadControlClusterTemperatureControlStruct( private const val TAG_COOLING_TEMP_SETPOINT = 2 private const val TAG_HEATING_TEMP_SETPOINT = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterTemperatureControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterTemperatureControlStruct { tlvReader.enterStructure(tlvTag) - val coolingTempOffset = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) - null - } - val heatingtTempOffset = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) - null - } - val coolingTempSetpoint = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) - null - } - val heatingTempSetpoint = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) - null - } - + val coolingTempOffset = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) + null + } + val heatingtTempOffset = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) + null + } + val coolingTempSetpoint = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) + null + } + val heatingTempSetpoint = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterTemperatureControlStruct(coolingTempOffset, heatingtTempOffset, coolingTempSetpoint, heatingTempSetpoint) + return DemandResponseLoadControlClusterTemperatureControlStruct( + coolingTempOffset, + heatingtTempOffset, + coolingTempSetpoint, + heatingTempSetpoint + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt index 3b1d50b42659e8..c8cc82e04d50eb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DescriptorClusterDeviceTypeStruct( - val deviceType: UInt, - val revision: UShort -) { +class DescriptorClusterDeviceTypeStruct(val deviceType: UInt, val revision: UShort) { override fun toString(): String = buildString { append("DescriptorClusterDeviceTypeStruct {\n") append("\tdeviceType : $deviceType\n") @@ -52,7 +47,7 @@ class DescriptorClusterDeviceTypeStruct( tlvReader.enterStructure(tlvTag) val deviceType = tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_TYPE)) val revision = tlvReader.getUShort(ContextSpecificTag(TAG_REVISION)) - + tlvReader.exitContainer() return DescriptorClusterDeviceTypeStruct(deviceType, revision) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt index cc8a218a8840a6..70a83556618698 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,9 +50,9 @@ class DescriptorClusterSemanticTagStruct( put(ContextSpecificTag(TAG_TAG), tag) if (label != null) { if (label.isPresent) { - val optlabel = label.get() - put(ContextSpecificTag(TAG_LABEL), optlabel) - } + val optlabel = label.get() + put(ContextSpecificTag(TAG_LABEL), optlabel) + } } else { putNull(ContextSpecificTag(TAG_LABEL)) } @@ -69,25 +68,27 @@ class DescriptorClusterSemanticTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DescriptorClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) - null - } + val mfgCode = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) + null + } val namespaceID = tlvReader.getUByte(ContextSpecificTag(TAG_NAMESPACE_I_D)) val tag = tlvReader.getUByte(ContextSpecificTag(TAG_TAG)) - val label = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) - null - } - + val label = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) + null + } + tlvReader.exitContainer() return DescriptorClusterSemanticTagStruct(mfgCode, namespaceID, tag, label) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt index 0972701ad34688..4649721a71284b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -73,25 +72,34 @@ class DeviceEnergyManagementClusterConstraintsStruct( tlvReader.enterStructure(tlvTag) val startTime = tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val maximumEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) - } else { - Optional.empty() - } - val loadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { - Optional.of(tlvReader.getByte(ContextSpecificTag(TAG_LOAD_CONTROL))) - } else { - Optional.empty() - } - + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val maximumEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) + } else { + Optional.empty() + } + val loadControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { + Optional.of(tlvReader.getByte(ContextSpecificTag(TAG_LOAD_CONTROL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterConstraintsStruct(startTime, duration, nominalPower, maximumEnergy, loadControl) + return DeviceEnergyManagementClusterConstraintsStruct( + startTime, + duration, + nominalPower, + maximumEnergy, + loadControl + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt index f75628b28ac4f9..c08ce3a1eaf582 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,12 +63,13 @@ class DeviceEnergyManagementClusterCostStruct( val costType = tlvReader.getUByte(ContextSpecificTag(TAG_COST_TYPE)) val value = tlvReader.getInt(ContextSpecificTag(TAG_VALUE)) val decimalPoints = tlvReader.getUByte(ContextSpecificTag(TAG_DECIMAL_POINTS)) - val currency = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_CURRENCY))) - } else { - Optional.empty() - } - + val currency = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_CURRENCY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return DeviceEnergyManagementClusterCostStruct(costType, value, decimalPoints, currency) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index bf3cf1d2b67774..f78288a7493666 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -62,9 +62,9 @@ class DeviceEnergyManagementClusterForecastStruct( put(ContextSpecificTag(TAG_END_TIME), endTime) if (earliestStartTime != null) { if (earliestStartTime.isPresent) { - val optearliestStartTime = earliestStartTime.get() - put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) - } + val optearliestStartTime = earliestStartTime.get() + put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) + } } else { putNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) } @@ -97,42 +97,56 @@ class DeviceEnergyManagementClusterForecastStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) val forecastID = tlvReader.getUInt(ContextSpecificTag(TAG_FORECAST_I_D)) - val activeSlotNumber = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - null - } + val activeSlotNumber = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + null + } val startTime = tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getUInt(ContextSpecificTag(TAG_END_TIME)) - val earliestStartTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_EARLIEST_START_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) - null - } - val latestEndTime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LATEST_END_TIME))) - } else { - Optional.empty() - } + val earliestStartTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_EARLIEST_START_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) + null + } + val latestEndTime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LATEST_END_TIME))) + } else { + Optional.empty() + } val isPausable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSABLE)) - val slots = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val slots = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } val forecastUpdateReason = tlvReader.getUByte(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterForecastStruct(forecastID, activeSlotNumber, startTime, endTime, earliestStartTime, latestEndTime, isPausable, slots, forecastUpdateReason) + return DeviceEnergyManagementClusterForecastStruct( + forecastID, + activeSlotNumber, + startTime, + endTime, + earliestStartTime, + latestEndTime, + isPausable, + slots, + forecastUpdateReason + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt index 188f6bffef9f73..eda6c168281800 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustCapabilityStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -40,10 +39,10 @@ class DeviceEnergyManagementClusterPowerAdjustCapabilityStruct( startStructure(tlvTag) if (powerAdjustCapability != null) { startArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) - for (item in powerAdjustCapability.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in powerAdjustCapability.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } else { putNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) } @@ -56,22 +55,26 @@ class DeviceEnergyManagementClusterPowerAdjustCapabilityStruct( private const val TAG_POWER_ADJUST_CAPABILITY = 0 private const val TAG_CAUSE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterPowerAdjustCapabilityStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterPowerAdjustCapabilityStruct { tlvReader.enterStructure(tlvTag) - val powerAdjustCapability = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) - null - } + val powerAdjustCapability = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_ADJUST_CAPABILITY)) + null + } val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterPowerAdjustCapabilityStruct(powerAdjustCapability, cause) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt index f03165bcf17f94..c1822bb573e344 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,10 +60,15 @@ class DeviceEnergyManagementClusterPowerAdjustStruct( val maxPower = tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER)) val minDuration = tlvReader.getUInt(ContextSpecificTag(TAG_MIN_DURATION)) val maxDuration = tlvReader.getUInt(ContextSpecificTag(TAG_MAX_DURATION)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterPowerAdjustStruct(minPower, maxPower, minDuration, maxDuration) + return DeviceEnergyManagementClusterPowerAdjustStruct( + minPower, + maxPower, + minDuration, + maxDuration + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt index 5be69214a8dfd4..5d4cef6567816d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -55,16 +54,20 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct( private const val TAG_NOMINAL_POWER = 1 private const val TAG_DURATION = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterSlotAdjustmentStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterSlotAdjustmentStruct { tlvReader.enterStructure(tlvTag) val slotIndex = tlvReader.getUByte(ContextSpecificTag(TAG_SLOT_INDEX)) - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterSlotAdjustmentStruct(slotIndex, nominalPower, duration) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index 55dd52b8b64b43..7759d960c31fde 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -110,10 +110,10 @@ class DeviceEnergyManagementClusterSlotStruct( if (costs.isPresent) { val optcosts = costs.get() startArray(ContextSpecificTag(TAG_COSTS)) - for (item in optcosts.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optcosts.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } if (minPowerAdjustment.isPresent) { val optminPowerAdjustment = minPowerAdjustment.get() @@ -162,81 +162,115 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration = tlvReader.getUInt(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPausable = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) - } else { - Optional.empty() - } - val minPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) - } else { - Optional.empty() - } - val maxPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) - } else { - Optional.empty() - } - val manufacturerESAState = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) - } else { - Optional.empty() - } - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val minPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) - } else { - Optional.empty() - } - val maxPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) - } else { - Optional.empty() - } - val nominalEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) - } else { - Optional.empty() - } - val costs = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val minPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val minDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - + val slotIsPausable = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSABLE))) + } else { + Optional.empty() + } + val minPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) + } else { + Optional.empty() + } + val maxPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) + } else { + Optional.empty() + } + val manufacturerESAState = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) + } else { + Optional.empty() + } + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val minPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) + } else { + Optional.empty() + } + val maxPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) + } else { + Optional.empty() + } + val nominalEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) + } else { + Optional.empty() + } + val costs = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val minPowerAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxPowerAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val minDurationAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxDurationAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterSlotStruct(minDuration, maxDuration, defaultDuration, elapsedSlotTime, remainingSlotTime, slotIsPausable, minPauseDuration, maxPauseDuration, manufacturerESAState, nominalPower, minPower, maxPower, nominalEnergy, costs, minPowerAdjustment, maxPowerAdjustment, minDurationAdjustment, maxDurationAdjustment) + return DeviceEnergyManagementClusterSlotStruct( + minDuration, + maxDuration, + defaultDuration, + elapsedSlotTime, + remainingSlotTime, + slotIsPausable, + minPauseDuration, + maxPauseDuration, + manufacturerESAState, + nominalPower, + minPower, + maxPower, + nominalEnergy, + costs, + minPowerAdjustment, + maxPowerAdjustment, + minDurationAdjustment, + maxDurationAdjustment + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementModeClusterModeOptionStruct.kt index e506d757bc4d25..c3ecf2539ef247 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,18 +55,22 @@ class DeviceEnergyManagementModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementModeClusterModeOptionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return DeviceEnergyManagementModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementModeClusterModeTagStruct.kt index 50409c33b33106..6d744ab290aa0e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementModeClusterModeTagStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -53,13 +52,14 @@ class DeviceEnergyManagementModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return DeviceEnergyManagementModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt index d250f1c10ccccc..3d61c5bccf50cf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class DishwasherModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return DishwasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt index 033e60f5419f37..584dc79028182c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("DishwasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class DishwasherModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return DishwasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt index 5f2b5c37f2d96e..f66b57f47660ca 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterCredentialStruct( - val credentialType: UByte, - val credentialIndex: UShort -) { +class DoorLockClusterCredentialStruct(val credentialType: UByte, val credentialIndex: UShort) { override fun toString(): String = buildString { append("DoorLockClusterCredentialStruct {\n") append("\tcredentialType : $credentialType\n") @@ -52,7 +47,7 @@ class DoorLockClusterCredentialStruct( tlvReader.enterStructure(tlvTag) val credentialType = tlvReader.getUByte(ContextSpecificTag(TAG_CREDENTIAL_TYPE)) val credentialIndex = tlvReader.getUShort(ContextSpecificTag(TAG_CREDENTIAL_INDEX)) - + tlvReader.exitContainer() return DoorLockClusterCredentialStruct(credentialType, credentialIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt index 0827d8124cf55e..9ae505db1e48b3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -44,33 +43,33 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( startStructure(tlvTag) if (importedResetTimestamp != null) { if (importedResetTimestamp.isPresent) { - val optimportedResetTimestamp = importedResetTimestamp.get() - put(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP), optimportedResetTimestamp) - } + val optimportedResetTimestamp = importedResetTimestamp.get() + put(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP), optimportedResetTimestamp) + } } else { putNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) } if (exportedResetTimestamp != null) { if (exportedResetTimestamp.isPresent) { - val optexportedResetTimestamp = exportedResetTimestamp.get() - put(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP), optexportedResetTimestamp) - } + val optexportedResetTimestamp = exportedResetTimestamp.get() + put(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP), optexportedResetTimestamp) + } } else { putNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) } if (importedResetSystime != null) { if (importedResetSystime.isPresent) { - val optimportedResetSystime = importedResetSystime.get() - put(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME), optimportedResetSystime) - } + val optimportedResetSystime = importedResetSystime.get() + put(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME), optimportedResetSystime) + } } else { putNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) } if (exportedResetSystime != null) { if (exportedResetSystime.isPresent) { - val optexportedResetSystime = exportedResetSystime.get() - put(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME), optexportedResetSystime) - } + val optexportedResetSystime = exportedResetSystime.get() + put(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME), optexportedResetSystime) + } } else { putNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) } @@ -84,52 +83,64 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( private const val TAG_IMPORTED_RESET_SYSTIME = 2 private const val TAG_EXPORTED_RESET_SYSTIME = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct { tlvReader.enterStructure(tlvTag) - val importedResetTimestamp = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) - null - } - val exportedResetTimestamp = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) - null - } - val importedResetSystime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) - null - } - val exportedResetSystime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) - null - } - + val importedResetTimestamp = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_TIMESTAMP)) + null + } + val exportedResetTimestamp = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_TIMESTAMP)) + null + } + val importedResetSystime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_IMPORTED_RESET_SYSTIME)) + null + } + val exportedResetSystime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EXPORTED_RESET_SYSTIME)) + null + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct(importedResetTimestamp, exportedResetTimestamp, importedResetSystime, exportedResetSystime) + return ElectricalEnergyMeasurementClusterCumulativeEnergyResetStruct( + importedResetTimestamp, + exportedResetTimestamp, + importedResetSystime, + exportedResetSystime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt index 397f1eab428ecf..46dff94ff6a1cb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,33 +71,46 @@ class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( private const val TAG_START_SYSTIME = 3 private const val TAG_END_SYSTIME = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { tlvReader.enterStructure(tlvTag) val energy = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY)) - val startTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) - } else { - Optional.empty() - } - val endTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) - } else { - Optional.empty() - } - val startSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) - } else { - Optional.empty() - } - val endSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) - } else { - Optional.empty() - } - + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct(energy, startTimestamp, endTimestamp, startSystime, endSystime) + return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + energy, + startTimestamp, + endTimestamp, + startSystime, + endSystime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt index 4e0ca217ce09fe..65ed89eee4272d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -90,44 +89,62 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( private const val TAG_FIXED_MIN = 6 private const val TAG_FIXED_TYPICAL = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { tlvReader.enterStructure(tlvTag) val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) - val percentMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) - } else { - Optional.empty() - } - val percentMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) - } else { - Optional.empty() - } - val percentTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) - } else { - Optional.empty() - } - val fixedMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) - } else { - Optional.empty() - } - val fixedMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) - } else { - Optional.empty() - } - val fixedTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) - } else { - Optional.empty() - } - + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct(rangeMin, rangeMax, percentMax, percentMin, percentTypical, fixedMax, fixedMin, fixedTypical) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt index b0ec26832b7c2d..b8f7a0f8ff429e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -64,23 +63,38 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( private const val TAG_MAX_MEASURED_VALUE = 3 private const val TAG_ACCURACY_RANGES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUShort(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) - val accuracyRanges = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct(measurementType, measured, minMeasuredValue, maxMeasuredValue, accuracyRanges) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt index 48533cc86b8586..54c2868f6dd8f0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterHarmonicMeasurementStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,16 +50,20 @@ class ElectricalPowerMeasurementClusterHarmonicMeasurementStruct( private const val TAG_ORDER = 0 private const val TAG_MEASUREMENT = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalPowerMeasurementClusterHarmonicMeasurementStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterHarmonicMeasurementStruct { tlvReader.enterStructure(tlvTag) val order = tlvReader.getUByte(ContextSpecificTag(TAG_ORDER)) - val measurement = if (!tlvReader.isNull()) { - tlvReader.getLong(ContextSpecificTag(TAG_MEASUREMENT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MEASUREMENT)) - null - } - + val measurement = + if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_MEASUREMENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MEASUREMENT)) + null + } + tlvReader.exitContainer() return ElectricalPowerMeasurementClusterHarmonicMeasurementStruct(order, measurement) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt index 7cbe39cec83fae..18e5534ff45480 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -90,44 +89,62 @@ class ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( private const val TAG_FIXED_MIN = 6 private const val TAG_FIXED_TYPICAL = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct { tlvReader.enterStructure(tlvTag) val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) - val percentMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) - } else { - Optional.empty() - } - val percentMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) - } else { - Optional.empty() - } - val percentTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) - } else { - Optional.empty() - } - val fixedMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) - } else { - Optional.empty() - } - val fixedMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) - } else { - Optional.empty() - } - val fixedTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) - } else { - Optional.empty() - } - + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct(rangeMin, rangeMax, percentMax, percentMin, percentTypical, fixedMax, fixedMin, fixedTypical) + return ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt index 63fa1a24a39a54..895b52e30fca5f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -64,23 +63,38 @@ class ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( private const val TAG_MAX_MEASURED_VALUE = 3 private const val TAG_ACCURACY_RANGES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalPowerMeasurementClusterMeasurementAccuracyStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementAccuracyStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUShort(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) - val accuracyRanges = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalPowerMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return ElectricalPowerMeasurementClusterMeasurementAccuracyStruct(measurementType, measured, minMeasuredValue, maxMeasuredValue, accuracyRanges) + return ElectricalPowerMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt index e612421d19d891..4550a6a514b22e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -108,55 +107,78 @@ class ElectricalPowerMeasurementClusterMeasurementRangeStruct( private const val TAG_MIN_SYSTIME = 9 private const val TAG_MAX_SYSTIME = 10 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalPowerMeasurementClusterMeasurementRangeStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalPowerMeasurementClusterMeasurementRangeStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUShort(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val min = tlvReader.getLong(ContextSpecificTag(TAG_MIN)) val max = tlvReader.getLong(ContextSpecificTag(TAG_MAX)) - val startTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) - } else { - Optional.empty() - } - val endTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) - } else { - Optional.empty() - } - val minTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_TIMESTAMP))) - } else { - Optional.empty() - } - val maxTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_TIMESTAMP))) - } else { - Optional.empty() - } - val startSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) - } else { - Optional.empty() - } - val endSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) - } else { - Optional.empty() - } - val minSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_SYSTIME))) - } else { - Optional.empty() - } - val maxSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_SYSTIME))) - } else { - Optional.empty() - } - + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val minTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_TIMESTAMP))) + } else { + Optional.empty() + } + val maxTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + val minSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_SYSTIME))) + } else { + Optional.empty() + } + val maxSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_SYSTIME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalPowerMeasurementClusterMeasurementRangeStruct(measurementType, min, max, startTimestamp, endTimestamp, minTimestamp, maxTimestamp, startSystime, endSystime, minSystime, maxSystime) + return ElectricalPowerMeasurementClusterMeasurementRangeStruct( + measurementType, + min, + max, + startTimestamp, + endTimestamp, + minTimestamp, + maxTimestamp, + startSystime, + endSystime, + minSystime, + maxSystime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt index 3ed256441cd2ff..eaa06f527c652f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -54,15 +53,17 @@ class EnergyEvseClusterChargingTargetScheduleStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct { tlvReader.enterStructure(tlvTag) - val dayOfWeekForSequence = tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) - val chargingTargets = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val dayOfWeekForSequence = + tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) + val chargingTargets = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return EnergyEvseClusterChargingTargetScheduleStruct(dayOfWeekForSequence, chargingTargets) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt index 72826868a15260..db61226e1adf55 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,21 +59,28 @@ class EnergyEvseClusterChargingTargetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetStruct { tlvReader.enterStructure(tlvTag) - val targetTimeMinutesPastMidnight = tlvReader.getUShort(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) - val targetSoC = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TARGET_SO_C))) - } else { - Optional.empty() - } - val addedEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) - } else { - Optional.empty() - } - + val targetTimeMinutesPastMidnight = + tlvReader.getUShort(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) + val targetSoC = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TARGET_SO_C))) + } else { + Optional.empty() + } + val addedEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterChargingTargetStruct(targetTimeMinutesPastMidnight, targetSoC, addedEnergy) + return EnergyEvseClusterChargingTargetStruct( + targetTimeMinutesPastMidnight, + targetSoC, + addedEnergy + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt index 19ee22542f25a9..96e2d9f64e59c0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class EnergyEvseModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return EnergyEvseModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeTagStruct.kt index c5c55fd1efc89e..e4a9a48c9244eb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class EnergyEvseModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("EnergyEvseModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class EnergyEvseModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return EnergyEvseModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt index 80e4c2b06d9cad..29980664d4cbec 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyPreferenceClusterBalanceStruct( - val step: UByte, - val label: Optional -) { +class EnergyPreferenceClusterBalanceStruct(val step: UByte, val label: Optional) { override fun toString(): String = buildString { append("EnergyPreferenceClusterBalanceStruct {\n") append("\tstep : $step\n") @@ -54,12 +50,13 @@ class EnergyPreferenceClusterBalanceStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyPreferenceClusterBalanceStruct { tlvReader.enterStructure(tlvTag) val step = tlvReader.getUByte(ContextSpecificTag(TAG_STEP)) - val label = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - + val label = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return EnergyPreferenceClusterBalanceStruct(step, label) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt index 2465dd492ace99..b5181c44417b6d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class FixedLabelClusterLabelStruct( - val label: String, - val value: String -) { +class FixedLabelClusterLabelStruct(val label: String, val value: String) { override fun toString(): String = buildString { append("FixedLabelClusterLabelStruct {\n") append("\tlabel : $label\n") @@ -52,7 +47,7 @@ class FixedLabelClusterLabelStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return FixedLabelClusterLabelStruct(label, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt index b2d6b7e97638e6..aa7528a466dece 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,14 +46,22 @@ class GeneralCommissioningClusterBasicCommissioningInfo( private const val TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS = 0 private const val TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralCommissioningClusterBasicCommissioningInfo { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralCommissioningClusterBasicCommissioningInfo { tlvReader.enterStructure(tlvTag) - val failSafeExpiryLengthSeconds = tlvReader.getUShort(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) - val maxCumulativeFailsafeSeconds = tlvReader.getUShort(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) - + val failSafeExpiryLengthSeconds = + tlvReader.getUShort(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) + val maxCumulativeFailsafeSeconds = + tlvReader.getUShort(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) + tlvReader.exitContainer() - return GeneralCommissioningClusterBasicCommissioningInfo(failSafeExpiryLengthSeconds, maxCumulativeFailsafeSeconds) + return GeneralCommissioningClusterBasicCommissioningInfo( + failSafeExpiryLengthSeconds, + maxCumulativeFailsafeSeconds + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt index 61f8691c5f053a..200b75dde048f4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -53,12 +52,18 @@ class GeneralDiagnosticsClusterNetworkInterface( put(ContextSpecificTag(TAG_NAME), name) put(ContextSpecificTag(TAG_IS_OPERATIONAL), isOperational) if (offPremiseServicesReachableIPv4 != null) { - put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), offPremiseServicesReachableIPv4) + put( + ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), + offPremiseServicesReachableIPv4 + ) } else { putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) } if (offPremiseServicesReachableIPv6 != null) { - put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), offPremiseServicesReachableIPv6) + put( + ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), + offPremiseServicesReachableIPv6 + ) } else { putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) } @@ -92,38 +97,51 @@ class GeneralDiagnosticsClusterNetworkInterface( tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val isOperational = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_OPERATIONAL)) - val offPremiseServicesReachableIPv4 = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - null - } - val offPremiseServicesReachableIPv6 = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - null - } + val offPremiseServicesReachableIPv4 = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + null + } + val offPremiseServicesReachableIPv6 = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + null + } val hardwareAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_HARDWARE_ADDRESS)) - val IPv4Addresses = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val IPv6Addresses = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val IPv4Addresses = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val IPv6Addresses = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) - + tlvReader.exitContainer() - return GeneralDiagnosticsClusterNetworkInterface(name, isOperational, offPremiseServicesReachableIPv4, offPremiseServicesReachableIPv6, hardwareAddress, IPv4Addresses, IPv6Addresses, type) + return GeneralDiagnosticsClusterNetworkInterface( + name, + isOperational, + offPremiseServicesReachableIPv4, + offPremiseServicesReachableIPv6, + hardwareAddress, + IPv4Addresses, + IPv6Addresses, + type + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt index ef8286072bfcfd..9d0155111d4207 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt @@ -66,20 +66,22 @@ class GroupKeyManagementClusterGroupInfoMapStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupInfoMapStruct { tlvReader.enterStructure(tlvTag) val groupId = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_ID)) - val endpoints = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - val groupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) - } else { - Optional.empty() - } + val endpoints = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + val groupName = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupInfoMapStruct(groupId, endpoints, groupName, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt index b40a261be6a411..e5f8ecb177a11b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class GroupKeyManagementClusterGroupKeyMapStruct( val groupId = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_ID)) val groupKeySetID = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupKeyMapStruct(groupId, groupKeySetID, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt index 86cb6fb3510b09..d68d0536b9bd30 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -99,47 +97,63 @@ class GroupKeyManagementClusterGroupKeySetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupKeySetStruct { tlvReader.enterStructure(tlvTag) val groupKeySetID = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) - val groupKeySecurityPolicy = tlvReader.getUByte(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) - val epochKey0 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) - null - } - val epochStartTime0 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - null - } - val epochKey1 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) - null - } - val epochStartTime1 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - null - } - val epochKey2 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) - null - } - val epochStartTime2 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - null - } - + val groupKeySecurityPolicy = + tlvReader.getUByte(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) + val epochKey0 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) + null + } + val epochStartTime0 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + null + } + val epochKey1 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) + null + } + val epochStartTime1 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + null + } + val epochKey2 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) + null + } + val epochStartTime2 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + null + } + tlvReader.exitContainer() - return GroupKeyManagementClusterGroupKeySetStruct(groupKeySetID, groupKeySecurityPolicy, epochKey0, epochStartTime0, epochKey1, epochStartTime1, epochKey2, epochStartTime2) + return GroupKeyManagementClusterGroupKeySetStruct( + groupKeySetID, + groupKeySecurityPolicy, + epochKey0, + epochStartTime0, + epochKey1, + epochStartTime1, + epochKey2, + epochStartTime2 + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt index c838f5450b4c90..99d8d0dfd05c83 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,14 +46,22 @@ class HepaFilterMonitoringClusterReplacementProductStruct( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): HepaFilterMonitoringClusterReplacementProductStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): HepaFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) - val productIdentifierType = tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierType = + tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) + val productIdentifierValue = + tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return HepaFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) + return HepaFilterMonitoringClusterReplacementProductStruct( + productIdentifierType, + productIdentifierValue + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt index a58e78c492ad56..8c6c2655546b12 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,16 +54,24 @@ class IcdManagementClusterMonitoringRegistrationStruct( private const val TAG_CLIENT_TYPE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): IcdManagementClusterMonitoringRegistrationStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): IcdManagementClusterMonitoringRegistrationStruct { tlvReader.enterStructure(tlvTag) val checkInNodeID = tlvReader.getULong(ContextSpecificTag(TAG_CHECK_IN_NODE_I_D)) val monitoredSubject = tlvReader.getULong(ContextSpecificTag(TAG_MONITORED_SUBJECT)) val clientType = tlvReader.getUByte(ContextSpecificTag(TAG_CLIENT_TYPE)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return IcdManagementClusterMonitoringRegistrationStruct(checkInNodeID, monitoredSubject, clientType, fabricIndex) + return IcdManagementClusterMonitoringRegistrationStruct( + checkInNodeID, + monitoredSubject, + clientType, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt index 869fc790e2c371..e8392fab770bf0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class LaundryWasherModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return LaundryWasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt index 1b9aaf99f45c57..a12e2840ead4ab 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("LaundryWasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class LaundryWasherModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): LaundryWasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return LaundryWasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt index 13d46092d3725f..2aaef4b767542e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,7 +60,7 @@ class MediaInputClusterInputInfoStruct( val inputType = tlvReader.getUByte(ContextSpecificTag(TAG_INPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val description = tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION)) - + tlvReader.exitContainer() return MediaInputClusterInputInfoStruct(index, inputType, name, description) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt index 6df4407304fc0d..518da6b739efc8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackClusterPlaybackPositionStruct( - val updatedAt: ULong, - val position: ULong? -) { +class MediaPlaybackClusterPlaybackPositionStruct(val updatedAt: ULong, val position: ULong?) { override fun toString(): String = buildString { append("MediaPlaybackClusterPlaybackPositionStruct {\n") append("\tupdatedAt : $updatedAt\n") @@ -55,13 +50,14 @@ class MediaPlaybackClusterPlaybackPositionStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterPlaybackPositionStruct { tlvReader.enterStructure(tlvTag) val updatedAt = tlvReader.getULong(ContextSpecificTag(TAG_UPDATED_AT)) - val position = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) - null - } - + val position = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterPlaybackPositionStruct(updatedAt, position) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt index b82ec49c17f735..dfd99da8565408 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -41,9 +40,9 @@ class MediaPlaybackClusterTrackAttributesStruct( put(ContextSpecificTag(TAG_LANGUAGE_CODE), languageCode) if (displayName != null) { if (displayName.isPresent) { - val optdisplayName = displayName.get() - put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) - } + val optdisplayName = displayName.get() + put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) + } } else { putNull(ContextSpecificTag(TAG_DISPLAY_NAME)) } @@ -58,17 +57,18 @@ class MediaPlaybackClusterTrackAttributesStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackAttributesStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val displayName = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) - null - } - + val displayName = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackAttributesStruct(languageCode, displayName) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt index f4c43f16e2337f..0571df7456c16e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -55,13 +53,17 @@ class MediaPlaybackClusterTrackStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getString(ContextSpecificTag(TAG_ID)) - val trackAttributes = if (!tlvReader.isNull()) { - MediaPlaybackClusterTrackAttributesStruct.fromTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) - null - } - + val trackAttributes = + if (!tlvReader.isNull()) { + MediaPlaybackClusterTrackAttributesStruct.fromTlv( + ContextSpecificTag(TAG_TRACK_ATTRIBUTES), + tlvReader + ) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackStruct(id, trackAttributes) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MessagesClusterMessageResponseOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MessagesClusterMessageResponseOptionStruct.kt index 481046bd6dadcb..8323af66ea03ca 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MessagesClusterMessageResponseOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MessagesClusterMessageResponseOptionStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,17 +55,19 @@ class MessagesClusterMessageResponseOptionStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessageResponseOptionStruct { tlvReader.enterStructure(tlvTag) - val messageResponseID = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D))) - } else { - Optional.empty() - } - val label = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - + val messageResponseID = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MESSAGE_RESPONSE_I_D))) + } else { + Optional.empty() + } + val label = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return MessagesClusterMessageResponseOptionStruct(messageResponseID, label) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MessagesClusterMessageStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MessagesClusterMessageStruct.kt index beafed57a597a1..14c573c396ca18 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MessagesClusterMessageStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MessagesClusterMessageStruct.kt @@ -65,10 +65,10 @@ class MessagesClusterMessageStruct( if (responses.isPresent) { val optresponses = responses.get() startArray(ContextSpecificTag(TAG_RESPONSES)) - for (item in optresponses.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optresponses.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -88,34 +88,47 @@ class MessagesClusterMessageStruct( val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D)) val priority = tlvReader.getUByte(ContextSpecificTag(TAG_PRIORITY)) val messageControl = tlvReader.getUByte(ContextSpecificTag(TAG_MESSAGE_CONTROL)) - val startTime = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val duration = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DURATION)) - null - } + val startTime = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) + null + } + val duration = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DURATION)) + null + } val messageText = tlvReader.getString(ContextSpecificTag(TAG_MESSAGE_TEXT)) - val responses = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSES))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RESPONSES)) - while(!tlvReader.isEndOfContainer()) { - add(MessagesClusterMessageResponseOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val responses = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSES))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_RESPONSES)) + while (!tlvReader.isEndOfContainer()) { + add(MessagesClusterMessageResponseOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return MessagesClusterMessageStruct(messageID, priority, messageControl, startTime, duration, messageText, responses) + return MessagesClusterMessageStruct( + messageID, + priority, + messageControl, + startTime, + duration, + messageText, + responses + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt index 90d2e905cad2b1..8af30d0c768cf7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class MicrowaveOvenModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt index 6ac44a062ca27a..ee00730c425f47 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MicrowaveOvenModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class MicrowaveOvenModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MicrowaveOvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt index ee501cf2d85532..558980bb83460a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class ModeSelectClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val semanticTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val semanticTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ModeSelectClusterModeOptionStruct(label, mode, semanticTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt index 323f73c99e7820..fe6cdd3b787f01 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ModeSelectClusterSemanticTagStruct( - val mfgCode: UShort, - val value: UShort -) { +class ModeSelectClusterSemanticTagStruct(val mfgCode: UShort, val value: UShort) { override fun toString(): String = buildString { append("ModeSelectClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -52,7 +47,7 @@ class ModeSelectClusterSemanticTagStruct( tlvReader.enterStructure(tlvTag) val mfgCode = tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ModeSelectClusterSemanticTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt index 443d3e377f6837..ebb7d9c32e5609 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,17 +45,17 @@ class NetworkCommissioningClusterNetworkInfoStruct( put(ContextSpecificTag(TAG_CONNECTED), connected) if (networkIdentifier != null) { if (networkIdentifier.isPresent) { - val optnetworkIdentifier = networkIdentifier.get() - put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) - } + val optnetworkIdentifier = networkIdentifier.get() + put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) + } } else { putNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) } if (clientIdentifier != null) { if (clientIdentifier.isPresent) { - val optclientIdentifier = clientIdentifier.get() - put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) - } + val optclientIdentifier = clientIdentifier.get() + put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) + } } else { putNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) } @@ -74,30 +73,37 @@ class NetworkCommissioningClusterNetworkInfoStruct( tlvReader.enterStructure(tlvTag) val networkID = tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_I_D)) val connected = tlvReader.getBoolean(ContextSpecificTag(TAG_CONNECTED)) - val networkIdentifier = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) - null - } - val clientIdentifier = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) - null - } - + val networkIdentifier = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) + null + } + val clientIdentifier = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) + null + } + tlvReader.exitContainer() - return NetworkCommissioningClusterNetworkInfoStruct(networkID, connected, networkIdentifier, clientIdentifier) + return NetworkCommissioningClusterNetworkInfoStruct( + networkID, + connected, + networkIdentifier, + clientIdentifier + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt index c052531cdda164..93df116f49e63e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,7 +70,10 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct( private const val TAG_RSSI = 6 private const val TAG_LQI = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): NetworkCommissioningClusterThreadInterfaceScanResultStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): NetworkCommissioningClusterThreadInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val panId = tlvReader.getUShort(ContextSpecificTag(TAG_PAN_ID)) val extendedPanId = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_ID)) @@ -82,10 +83,19 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct( val extendedAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_EXTENDED_ADDRESS)) val rssi = tlvReader.getByte(ContextSpecificTag(TAG_RSSI)) val lqi = tlvReader.getUByte(ContextSpecificTag(TAG_LQI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterThreadInterfaceScanResultStruct(panId, extendedPanId, networkName, channel, version, extendedAddress, rssi, lqi) + return NetworkCommissioningClusterThreadInterfaceScanResultStruct( + panId, + extendedPanId, + networkName, + channel, + version, + extendedAddress, + rssi, + lqi + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt index 85c6cf71f7c47b..ffbb05f45a6b51 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,7 +62,10 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( private const val TAG_WI_FI_BAND = 4 private const val TAG_RSSI = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val security = tlvReader.getUByte(ContextSpecificTag(TAG_SECURITY)) val ssid = tlvReader.getByteArray(ContextSpecificTag(TAG_SSID)) @@ -72,10 +73,17 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( val channel = tlvReader.getUShort(ContextSpecificTag(TAG_CHANNEL)) val wiFiBand = tlvReader.getUByte(ContextSpecificTag(TAG_WI_FI_BAND)) val rssi = tlvReader.getByte(ContextSpecificTag(TAG_RSSI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterWiFiInterfaceScanResultStruct(security, ssid, bssid, channel, wiFiBand, rssi) + return NetworkCommissioningClusterWiFiInterfaceScanResultStruct( + security, + ssid, + bssid, + channel, + wiFiBand, + rssi + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt index 7c980f2eaa2d01..89b9428c741564 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,7 +62,10 @@ class OperationalCredentialsClusterFabricDescriptorStruct( private const val TAG_LABEL = 5 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalCredentialsClusterFabricDescriptorStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OperationalCredentialsClusterFabricDescriptorStruct { tlvReader.enterStructure(tlvTag) val rootPublicKey = tlvReader.getByteArray(ContextSpecificTag(TAG_ROOT_PUBLIC_KEY)) val vendorID = tlvReader.getUShort(ContextSpecificTag(TAG_VENDOR_I_D)) @@ -72,10 +73,17 @@ class OperationalCredentialsClusterFabricDescriptorStruct( val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OperationalCredentialsClusterFabricDescriptorStruct(rootPublicKey, vendorID, fabricID, nodeID, label, fabricIndex) + return OperationalCredentialsClusterFabricDescriptorStruct( + rootPublicKey, + vendorID, + fabricID, + nodeID, + label, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt index 1a27ee6624fe40..3a104b0d78b127 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -59,14 +57,15 @@ class OperationalCredentialsClusterNOCStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalCredentialsClusterNOCStruct { tlvReader.enterStructure(tlvTag) val noc = tlvReader.getByteArray(ContextSpecificTag(TAG_NOC)) - val icac = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) - null - } + val icac = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return OperationalCredentialsClusterNOCStruct(noc, icac, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt index 24ddb76ae228ca..f1d7a22e7e757b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -61,20 +60,26 @@ class OperationalStateClusterErrorStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return OperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt index 95645f734ce9ef..d08dc7aa0df6e9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,15 +53,19 @@ class OperationalStateClusterOperationalStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return OperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt index a8363ebd687c3d..f9dd92cc8640f3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,15 +50,22 @@ class OtaSoftwareUpdateRequestorClusterProviderLocation( private const val TAG_ENDPOINT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OtaSoftwareUpdateRequestorClusterProviderLocation { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterProviderLocation { tlvReader.enterStructure(tlvTag) val providerNodeID = tlvReader.getULong(ContextSpecificTag(TAG_PROVIDER_NODE_I_D)) val endpoint = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterProviderLocation(providerNodeID, endpoint, fabricIndex) + return OtaSoftwareUpdateRequestorClusterProviderLocation( + providerNodeID, + endpoint, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt index 825b5246771055..3ca1059ea25628 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,23 +57,32 @@ class OvenCavityOperationalStateClusterErrorStateStruct( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenCavityOperationalStateClusterErrorStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return OvenCavityOperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt index 2c051ce55bad80..f66b7a09928db4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,18 +50,25 @@ class OvenCavityOperationalStateClusterOperationalStateStruct( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenCavityOperationalStateClusterOperationalStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return OvenCavityOperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt index 47fda3f789599e..ba8bad6b42ff54 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class OvenModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return OvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt index 3715c9253bd394..4ba9d368de022f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("OvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class OvenModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return OvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt index 93b2e01e8dcd67..8b9487ac66f3e3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -58,21 +57,23 @@ class PowerSourceClusterBatChargeFaultChangeType( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt index f5c4803e0482ac..6b849cc5874313 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,10 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeType( - val current: List, - val previous: List -) { +class PowerSourceClusterBatFaultChangeType(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeType {\n") append("\tcurrent : $current\n") @@ -58,21 +54,23 @@ class PowerSourceClusterBatFaultChangeType( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt index 0eb132ceb49b1e..9354883b16e760 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,10 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeType( - val current: List, - val previous: List -) { +class PowerSourceClusterWiredFaultChangeType(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeType {\n") append("\tcurrent : $current\n") @@ -58,21 +54,23 @@ class PowerSourceClusterWiredFaultChangeType( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt index 59482e83c5039d..cd01932bc3f167 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,21 +55,34 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add( + RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct(label, mode, modeTags) + return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( + label, + mode, + modeTags + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt index 2ec589a6c0df35..9faf469741368c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,15 +50,19 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt index a79f2a02599eba..a8e74c89f3ad1d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class RvcCleanModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcCleanModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt index 88ea7b7b2f7002..ce35ad9a5a9960 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcCleanModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("RvcCleanModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class RvcCleanModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcCleanModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcCleanModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt index 20e4ab7ba0a318..6fa68a81b810ad 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -61,20 +60,26 @@ class RvcOperationalStateClusterErrorStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return RvcOperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt index 1d7445a75f0ac5..f21d5ecb4da1cf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,18 +50,25 @@ class RvcOperationalStateClusterOperationalStateStruct( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterOperationalStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return RvcOperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt index c98a49235c774f..f4193b91fac485 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class RvcRunModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcRunModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt index d9c65679552d63..7ad69693847d17 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcRunModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("RvcRunModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class RvcRunModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcRunModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcRunModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt index 90b6fb8bfb24d9..1a14970ba2bd58 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ScenesManagementClusterAttributeValuePair( - val attributeID: UInt, - val attributeValue: UInt -) { +class ScenesManagementClusterAttributeValuePair(val attributeID: UInt, val attributeValue: UInt) { override fun toString(): String = buildString { append("ScenesManagementClusterAttributeValuePair {\n") append("\tattributeID : $attributeID\n") @@ -52,7 +47,7 @@ class ScenesManagementClusterAttributeValuePair( tlvReader.enterStructure(tlvTag) val attributeID = tlvReader.getUInt(ContextSpecificTag(TAG_ATTRIBUTE_I_D)) val attributeValue = tlvReader.getUInt(ContextSpecificTag(TAG_ATTRIBUTE_VALUE)) - + tlvReader.exitContainer() return ScenesManagementClusterAttributeValuePair(attributeID, attributeValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt index 9a7e49546361d1..516c53bfb62604 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -55,14 +54,15 @@ class ScenesManagementClusterExtensionFieldSet( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterExtensionFieldSet { tlvReader.enterStructure(tlvTag) val clusterID = tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER_I_D)) - val attributeValueList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val attributeValueList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ScenesManagementClusterExtensionFieldSet(clusterID, attributeValueList) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt index ea23bcb97924f6..5a753f4acf803d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,10 +70,17 @@ class ScenesManagementClusterSceneInfoStruct( val sceneValid = tlvReader.getBoolean(ContextSpecificTag(TAG_SCENE_VALID)) val remainingCapacity = tlvReader.getUByte(ContextSpecificTag(TAG_REMAINING_CAPACITY)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return ScenesManagementClusterSceneInfoStruct(sceneCount, currentScene, currentGroup, sceneValid, remainingCapacity, fabricIndex) + return ScenesManagementClusterSceneInfoStruct( + sceneCount, + currentScene, + currentGroup, + sceneValid, + remainingCapacity, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterHomeLocationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterHomeLocationStruct.kt index 7bd99cab1be098..5af3730a4460a8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterHomeLocationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterHomeLocationStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -63,19 +61,21 @@ class ServiceAreaClusterHomeLocationStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ServiceAreaClusterHomeLocationStruct { tlvReader.enterStructure(tlvTag) val locationName = tlvReader.getString(ContextSpecificTag(TAG_LOCATION_NAME)) - val floorNumber = if (!tlvReader.isNull()) { - tlvReader.getShort(ContextSpecificTag(TAG_FLOOR_NUMBER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FLOOR_NUMBER)) - null - } - val areaType = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_AREA_TYPE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AREA_TYPE)) - null - } - + val floorNumber = + if (!tlvReader.isNull()) { + tlvReader.getShort(ContextSpecificTag(TAG_FLOOR_NUMBER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FLOOR_NUMBER)) + null + } + val areaType = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_AREA_TYPE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AREA_TYPE)) + null + } + tlvReader.exitContainer() return ServiceAreaClusterHomeLocationStruct(locationName, floorNumber, areaType) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterLocationInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterLocationInfoStruct.kt index c1ef0f3be6660d..c53b65c2dbb22f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterLocationInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterLocationInfoStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -74,34 +72,46 @@ class ServiceAreaClusterLocationInfoStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ServiceAreaClusterLocationInfoStruct { tlvReader.enterStructure(tlvTag) - val locationInfo = if (!tlvReader.isNull()) { - ServiceAreaClusterHomeLocationStruct.fromTlv(ContextSpecificTag(TAG_LOCATION_INFO), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LOCATION_INFO)) - null - } - val landmarkTag = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_LANDMARK_TAG)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LANDMARK_TAG)) - null - } - val positionTag = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_POSITION_TAG)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POSITION_TAG)) - null - } - val surfaceTag = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_SURFACE_TAG)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SURFACE_TAG)) - null - } - + val locationInfo = + if (!tlvReader.isNull()) { + ServiceAreaClusterHomeLocationStruct.fromTlv( + ContextSpecificTag(TAG_LOCATION_INFO), + tlvReader + ) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LOCATION_INFO)) + null + } + val landmarkTag = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_LANDMARK_TAG)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LANDMARK_TAG)) + null + } + val positionTag = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_POSITION_TAG)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POSITION_TAG)) + null + } + val surfaceTag = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_SURFACE_TAG)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SURFACE_TAG)) + null + } + tlvReader.exitContainer() - return ServiceAreaClusterLocationInfoStruct(locationInfo, landmarkTag, positionTag, surfaceTag) + return ServiceAreaClusterLocationInfoStruct( + locationInfo, + landmarkTag, + positionTag, + surfaceTag + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterLocationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterLocationStruct.kt index e83ed81b031a85..0a5b5aa3a825b4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterLocationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterLocationStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -59,14 +57,19 @@ class ServiceAreaClusterLocationStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ServiceAreaClusterLocationStruct { tlvReader.enterStructure(tlvTag) val locationID = tlvReader.getUInt(ContextSpecificTag(TAG_LOCATION_I_D)) - val mapID = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_MAP_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MAP_I_D)) - null - } - val locationInfo = ServiceAreaClusterLocationInfoStruct.fromTlv(ContextSpecificTag(TAG_LOCATION_INFO), tlvReader) - + val mapID = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_MAP_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MAP_I_D)) + null + } + val locationInfo = + ServiceAreaClusterLocationInfoStruct.fromTlv( + ContextSpecificTag(TAG_LOCATION_INFO), + tlvReader + ) + tlvReader.exitContainer() return ServiceAreaClusterLocationStruct(locationID, mapID, locationInfo) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterMapStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterMapStruct.kt index 617267688c00f7..3109c9bcb82b76 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterMapStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterMapStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ServiceAreaClusterMapStruct( - val mapID: UByte, - val name: String -) { +class ServiceAreaClusterMapStruct(val mapID: UByte, val name: String) { override fun toString(): String = buildString { append("ServiceAreaClusterMapStruct {\n") append("\tmapID : $mapID\n") @@ -52,7 +47,7 @@ class ServiceAreaClusterMapStruct( tlvReader.enterStructure(tlvTag) val mapID = tlvReader.getUByte(ContextSpecificTag(TAG_MAP_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return ServiceAreaClusterMapStruct(mapID, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterProgressStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterProgressStruct.kt index cf863c618bba66..a5dac6e470d299 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterProgressStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ServiceAreaClusterProgressStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,17 +45,17 @@ class ServiceAreaClusterProgressStruct( put(ContextSpecificTag(TAG_STATUS), status) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (estimatedTime != null) { if (estimatedTime.isPresent) { - val optestimatedTime = estimatedTime.get() - put(ContextSpecificTag(TAG_ESTIMATED_TIME), optestimatedTime) - } + val optestimatedTime = estimatedTime.get() + put(ContextSpecificTag(TAG_ESTIMATED_TIME), optestimatedTime) + } } else { putNull(ContextSpecificTag(TAG_ESTIMATED_TIME)) } @@ -74,30 +73,37 @@ class ServiceAreaClusterProgressStruct( tlvReader.enterStructure(tlvTag) val locationID = tlvReader.getUInt(ContextSpecificTag(TAG_LOCATION_I_D)) val status = tlvReader.getUByte(ContextSpecificTag(TAG_STATUS)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val estimatedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ESTIMATED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ESTIMATED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ESTIMATED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val estimatedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ESTIMATED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ESTIMATED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ESTIMATED_TIME)) + null + } + tlvReader.exitContainer() - return ServiceAreaClusterProgressStruct(locationID, status, totalOperationalTime, estimatedTime) + return ServiceAreaClusterProgressStruct( + locationID, + status, + totalOperationalTime, + estimatedTime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt index 75b362e21df943..b8f67a51a60beb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -75,30 +74,40 @@ class SoftwareDiagnosticsClusterThreadMetricsStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterThreadMetricsStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val stackFreeCurrent = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) - } else { - Optional.empty() - } - val stackFreeMinimum = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) - } else { - Optional.empty() - } - val stackSize = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_SIZE))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val stackFreeCurrent = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) + } else { + Optional.empty() + } + val stackFreeMinimum = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) + } else { + Optional.empty() + } + val stackSize = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_SIZE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return SoftwareDiagnosticsClusterThreadMetricsStruct(id, name, stackFreeCurrent, stackFreeMinimum, stackSize) + return SoftwareDiagnosticsClusterThreadMetricsStruct( + id, + name, + stackFreeCurrent, + stackFreeMinimum, + stackSize + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt index 804fa744fe4660..d1c115ff44e58e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TargetNavigatorClusterTargetInfoStruct( - val identifier: UByte, - val name: String -) { +class TargetNavigatorClusterTargetInfoStruct(val identifier: UByte, val name: String) { override fun toString(): String = buildString { append("TargetNavigatorClusterTargetInfoStruct {\n") append("\tidentifier : $identifier\n") @@ -52,7 +47,7 @@ class TargetNavigatorClusterTargetInfoStruct( tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getUByte(ContextSpecificTag(TAG_IDENTIFIER)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetInfoStruct(identifier, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt index be590ab0cbc7f8..498a7a1ee039f9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,9 +53,9 @@ class ThermostatClusterPresetStruct( put(ContextSpecificTag(TAG_PRESET_SCENARIO), presetScenario) if (name != null) { if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } } else { putNull(ContextSpecificTag(TAG_NAME)) } @@ -87,43 +86,55 @@ class ThermostatClusterPresetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } + val presetHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } val presetScenario = tlvReader.getUByte(ContextSpecificTag(TAG_PRESET_SCENARIO)) - val name = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NAME)) - null - } - val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - val builtIn = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NAME)) + null + } + val coolingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + val builtIn = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterPresetStruct(presetHandle, presetScenario, name, coolingSetpoint, heatingSetpoint, builtIn) + return ThermostatClusterPresetStruct( + presetHandle, + presetScenario, + name, + coolingSetpoint, + heatingSetpoint, + builtIn + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt index e9d029d6a542f3..d33ca6f93fdd6b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class ThermostatClusterPresetTypeStruct( val presetScenario = tlvReader.getUByte(ContextSpecificTag(TAG_PRESET_SCENARIO)) val numberOfPresets = tlvReader.getUByte(ContextSpecificTag(TAG_NUMBER_OF_PRESETS)) val presetTypeFeatures = tlvReader.getUShort(ContextSpecificTag(TAG_PRESET_TYPE_FEATURES)) - + tlvReader.exitContainer() return ThermostatClusterPresetTypeStruct(presetScenario, numberOfPresets, presetTypeFeatures) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt index 1ebb7e6e3c7e03..80a2e263806dda 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,19 +56,21 @@ class ThermostatClusterQueuedPresetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterQueuedPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } - val transitionTimestamp = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - null - } - + val presetHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } + val transitionTimestamp = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + null + } + tlvReader.exitContainer() return ThermostatClusterQueuedPresetStruct(presetHandle, transitionTimestamp) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt index 29c6a46bc3850e..25b8ff012cf7bc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt @@ -67,9 +67,9 @@ class ThermostatClusterScheduleStruct( endArray() if (builtIn != null) { if (builtIn.isPresent) { - val optbuiltIn = builtIn.get() - put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) - } + val optbuiltIn = builtIn.get() + put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) + } } else { putNull(ContextSpecificTag(TAG_BUILT_IN)) } @@ -87,44 +87,56 @@ class ThermostatClusterScheduleStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleStruct { tlvReader.enterStructure(tlvTag) - val scheduleHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - null - } + val scheduleHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + null + } val systemMode = tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val transitions = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val builtIn = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val presetHandle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val transitions = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val builtIn = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterScheduleStruct(scheduleHandle, systemMode, name, presetHandle, transitions, builtIn) + return ThermostatClusterScheduleStruct( + scheduleHandle, + systemMode, + name, + presetHandle, + transitions, + builtIn + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt index 1bd8bfe8cbf3be..bd9e4b6e3ca842 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -80,30 +79,41 @@ class ThermostatClusterScheduleTransitionStruct( tlvReader.enterStructure(tlvTag) val dayOfWeek = tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK)) val transitionTime = tlvReader.getUShort(ContextSpecificTag(TAG_TRANSITION_TIME)) - val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val systemMode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE))) - } else { - Optional.empty() - } - val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - + val presetHandle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val systemMode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE))) + } else { + Optional.empty() + } + val coolingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ThermostatClusterScheduleTransitionStruct(dayOfWeek, transitionTime, presetHandle, systemMode, coolingSetpoint, heatingSetpoint) + return ThermostatClusterScheduleTransitionStruct( + dayOfWeek, + transitionTime, + presetHandle, + systemMode, + coolingSetpoint, + heatingSetpoint + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt index 781f9fdd1aee97..91135f990547ff 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,10 +55,14 @@ class ThermostatClusterScheduleTypeStruct( val systemMode = tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE)) val numberOfSchedules = tlvReader.getUByte(ContextSpecificTag(TAG_NUMBER_OF_SCHEDULES)) val scheduleTypeFeatures = tlvReader.getUShort(ContextSpecificTag(TAG_SCHEDULE_TYPE_FEATURES)) - + tlvReader.exitContainer() - return ThermostatClusterScheduleTypeStruct(systemMode, numberOfSchedules, scheduleTypeFeatures) + return ThermostatClusterScheduleTypeStruct( + systemMode, + numberOfSchedules, + scheduleTypeFeatures + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt index 98721edcba9faa..597fce1f35e644 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,25 +58,34 @@ class ThermostatClusterWeeklyScheduleTransitionStruct( private const val TAG_HEAT_SETPOINT = 1 private const val TAG_COOL_SETPOINT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterWeeklyScheduleTransitionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThermostatClusterWeeklyScheduleTransitionStruct { tlvReader.enterStructure(tlvTag) val transitionTime = tlvReader.getUShort(ContextSpecificTag(TAG_TRANSITION_TIME)) - val heatSetpoint = if (!tlvReader.isNull()) { - tlvReader.getShort(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - null - } - val coolSetpoint = if (!tlvReader.isNull()) { - tlvReader.getShort(ContextSpecificTag(TAG_COOL_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - null - } - + val heatSetpoint = + if (!tlvReader.isNull()) { + tlvReader.getShort(ContextSpecificTag(TAG_HEAT_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) + null + } + val coolSetpoint = + if (!tlvReader.isNull()) { + tlvReader.getShort(ContextSpecificTag(TAG_COOL_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) + null + } + tlvReader.exitContainer() - return ThermostatClusterWeeklyScheduleTransitionStruct(transitionTime, heatSetpoint, coolSetpoint) + return ThermostatClusterWeeklyScheduleTransitionStruct( + transitionTime, + heatSetpoint, + coolSetpoint + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt index 21ee03ed5e51b3..c3fc752f705a55 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -104,7 +102,10 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct( private const val TAG_FULL_NETWORK_DATA = 12 private const val TAG_IS_CHILD = 13 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterNeighborTableStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterNeighborTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val age = tlvReader.getUInt(ContextSpecificTag(TAG_AGE)) @@ -112,28 +113,45 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct( val linkFrameCounter = tlvReader.getUInt(ContextSpecificTag(TAG_LINK_FRAME_COUNTER)) val mleFrameCounter = tlvReader.getUInt(ContextSpecificTag(TAG_MLE_FRAME_COUNTER)) val lqi = tlvReader.getUByte(ContextSpecificTag(TAG_LQI)) - val averageRssi = if (!tlvReader.isNull()) { - tlvReader.getByte(ContextSpecificTag(TAG_AVERAGE_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) - null - } - val lastRssi = if (!tlvReader.isNull()) { - tlvReader.getByte(ContextSpecificTag(TAG_LAST_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) - null - } + val averageRssi = + if (!tlvReader.isNull()) { + tlvReader.getByte(ContextSpecificTag(TAG_AVERAGE_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) + null + } + val lastRssi = + if (!tlvReader.isNull()) { + tlvReader.getByte(ContextSpecificTag(TAG_LAST_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) + null + } val frameErrorRate = tlvReader.getUByte(ContextSpecificTag(TAG_FRAME_ERROR_RATE)) val messageErrorRate = tlvReader.getUByte(ContextSpecificTag(TAG_MESSAGE_ERROR_RATE)) val rxOnWhenIdle = tlvReader.getBoolean(ContextSpecificTag(TAG_RX_ON_WHEN_IDLE)) val fullThreadDevice = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_THREAD_DEVICE)) val fullNetworkData = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_NETWORK_DATA)) val isChild = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_CHILD)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterNeighborTableStruct(extAddress, age, rloc16, linkFrameCounter, mleFrameCounter, lqi, averageRssi, lastRssi, frameErrorRate, messageErrorRate, rxOnWhenIdle, fullThreadDevice, fullNetworkData, isChild) + return ThreadNetworkDiagnosticsClusterNeighborTableStruct( + extAddress, + age, + rloc16, + linkFrameCounter, + mleFrameCounter, + lqi, + averageRssi, + lastRssi, + frameErrorRate, + messageErrorRate, + rxOnWhenIdle, + fullThreadDevice, + fullNetworkData, + isChild + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt index 91975101984aaa..8babb9d7bc1680 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -88,24 +86,45 @@ class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( private const val TAG_SECURITY_POLICY_PRESENT = 10 private const val TAG_CHANNEL_MASK_PRESENT = 11 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { tlvReader.enterStructure(tlvTag) - val activeTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) - val pendingTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) + val activeTimestampPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) + val pendingTimestampPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) val masterKeyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MASTER_KEY_PRESENT)) val networkNamePresent = tlvReader.getBoolean(ContextSpecificTag(TAG_NETWORK_NAME_PRESENT)) - val extendedPanIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) - val meshLocalPrefixPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) + val extendedPanIdPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) + val meshLocalPrefixPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) val delayPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_DELAY_PRESENT)) val panIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PAN_ID_PRESENT)) val channelPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_PRESENT)) val pskcPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PSKC_PRESENT)) - val securityPolicyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) + val securityPolicyPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) val channelMaskPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_MASK_PRESENT)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents(activeTimestampPresent, pendingTimestampPresent, masterKeyPresent, networkNamePresent, extendedPanIdPresent, meshLocalPrefixPresent, delayPresent, panIdPresent, channelPresent, pskcPresent, securityPolicyPresent, channelMaskPresent) + return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( + activeTimestampPresent, + pendingTimestampPresent, + masterKeyPresent, + networkNamePresent, + extendedPanIdPresent, + meshLocalPrefixPresent, + delayPresent, + panIdPresent, + channelPresent, + pskcPresent, + securityPolicyPresent, + channelMaskPresent + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt index b2b470b5765c0d..21bfbb8c4e950c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -80,7 +78,10 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct( private const val TAG_ALLOCATED = 8 private const val TAG_LINK_ESTABLISHED = 9 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterRouteTableStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterRouteTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val rloc16 = tlvReader.getUShort(ContextSpecificTag(TAG_RLOC16)) @@ -92,10 +93,21 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct( val age = tlvReader.getUByte(ContextSpecificTag(TAG_AGE)) val allocated = tlvReader.getBoolean(ContextSpecificTag(TAG_ALLOCATED)) val linkEstablished = tlvReader.getBoolean(ContextSpecificTag(TAG_LINK_ESTABLISHED)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterRouteTableStruct(extAddress, rloc16, routerId, nextHop, pathCost, LQIIn, LQIOut, age, allocated, linkEstablished) + return ThreadNetworkDiagnosticsClusterRouteTableStruct( + extAddress, + rloc16, + routerId, + nextHop, + pathCost, + LQIIn, + LQIOut, + age, + allocated, + linkEstablished + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt index 3228a78b13b000..720cdd6c854a72 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterSecurityPolicy( - val rotationTime: UShort, - val flags: UShort -) { +class ThreadNetworkDiagnosticsClusterSecurityPolicy(val rotationTime: UShort, val flags: UShort) { override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterSecurityPolicy {\n") append("\trotationTime : $rotationTime\n") @@ -52,7 +47,7 @@ class ThreadNetworkDiagnosticsClusterSecurityPolicy( tlvReader.enterStructure(tlvTag) val rotationTime = tlvReader.getUShort(ContextSpecificTag(TAG_ROTATION_TIME)) val flags = tlvReader.getUShort(ContextSpecificTag(TAG_FLAGS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterSecurityPolicy(rotationTime, flags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDirectoryClusterThreadNetworkStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDirectoryClusterThreadNetworkStruct.kt index c1d0dc7c684d3f..f7fb08d535fef5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDirectoryClusterThreadNetworkStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDirectoryClusterThreadNetworkStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,15 @@ class ThreadNetworkDirectoryClusterThreadNetworkStruct( private const val TAG_NETWORK_NAME = 1 private const val TAG_CHANNEL = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDirectoryClusterThreadNetworkStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDirectoryClusterThreadNetworkStruct { tlvReader.enterStructure(tlvTag) val extendedPanID = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_I_D)) val networkName = tlvReader.getString(ContextSpecificTag(TAG_NETWORK_NAME)) val channel = tlvReader.getUShort(ContextSpecificTag(TAG_CHANNEL)) - + tlvReader.exitContainer() return ThreadNetworkDirectoryClusterThreadNetworkStruct(extendedPanID, networkName, channel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt index 366d9e19dc429b..b74d29b91fbebe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,13 +58,14 @@ class TimeSynchronizationClusterDSTOffsetStruct( tlvReader.enterStructure(tlvTag) val offset = tlvReader.getInt(ContextSpecificTag(TAG_OFFSET)) val validStarting = tlvReader.getULong(ContextSpecificTag(TAG_VALID_STARTING)) - val validUntil = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) - null - } - + val validUntil = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) + null + } + tlvReader.exitContainer() return TimeSynchronizationClusterDSTOffsetStruct(offset, validStarting, validUntil) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt index 7c6440f0f2a618..6681fb2948b29b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,14 @@ class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct( private const val TAG_NODE_I_D = 0 private const val TAG_ENDPOINT = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct(nodeID, endpoint) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt index d8b7a7a33d130e..ac2e8efd626715 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -59,12 +58,13 @@ class TimeSynchronizationClusterTimeZoneStruct( tlvReader.enterStructure(tlvTag) val offset = tlvReader.getInt(ContextSpecificTag(TAG_OFFSET)) val validAt = tlvReader.getULong(ContextSpecificTag(TAG_VALID_AT)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStruct(offset, validAt, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt index 1e91548ed51086..4e966f6c36021e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,15 @@ class TimeSynchronizationClusterTrustedTimeSourceStruct( private const val TAG_NODE_I_D = 1 private const val TAG_ENDPOINT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTrustedTimeSourceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): TimeSynchronizationClusterTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterTrustedTimeSourceStruct(fabricIndex, nodeID, endpoint) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt index a78f035f9d5e70..b308907db2a90c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,9 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterDoubleNestedStructList( - val a: List -) { +class UnitTestingClusterDoubleNestedStructList(val a: List) { override fun toString(): String = buildString { append("UnitTestingClusterDoubleNestedStructList {\n") append("\ta : $a\n") @@ -50,14 +47,15 @@ class UnitTestingClusterDoubleNestedStructList( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterDoubleNestedStructList { tlvReader.enterStructure(tlvTag) - val a = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_A)) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val a = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_A)) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterDoubleNestedStructList(a) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt index 21b9bab077f473..d1bb92e17a739b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class UnitTestingClusterNestedStruct( val a = tlvReader.getUByte(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - + tlvReader.exitContainer() return UnitTestingClusterNestedStruct(a, b, c) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt index 653e0e8f3a39d8..3e58a31e5c24f3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -89,35 +88,39 @@ class UnitTestingClusterNestedStructList( val a = tlvReader.getUByte(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - val d = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_D)) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val e = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_E)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val f = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_F)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val g = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_G)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val d = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_D)) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val e = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_E)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val f = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_F)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val g = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_G)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterNestedStructList(a, b, c, d, e, f, g) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt index 279d19e7f4ed48..719fc4459ca37f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt @@ -69,9 +69,9 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } if (nullableOptionalInt != null) { if (nullableOptionalInt.isPresent) { - val optnullableOptionalInt = nullableOptionalInt.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) - } + val optnullableOptionalInt = nullableOptionalInt.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) } @@ -86,9 +86,9 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } if (nullableOptionalString != null) { if (nullableOptionalString.isPresent) { - val optnullableOptionalString = nullableOptionalString.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) - } + val optnullableOptionalString = nullableOptionalString.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) } @@ -103,38 +103,38 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } if (nullableOptionalStruct != null) { if (nullableOptionalStruct.isPresent) { - val optnullableOptionalStruct = nullableOptionalStruct.get() - optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) - } + val optnullableOptionalStruct = nullableOptionalStruct.get() + optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) } if (nullableList != null) { startArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - for (item in nullableList.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in nullableList.iterator()) { + put(AnonymousTag, item) + } + endArray() } else { putNull(ContextSpecificTag(TAG_NULLABLE_LIST)) } if (optionalList.isPresent) { val optoptionalList = optionalList.get() startArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - for (item in optoptionalList.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optoptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() } if (nullableOptionalList != null) { if (nullableOptionalList.isPresent) { - val optnullableOptionalList = nullableOptionalList.get() - startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - for (item in optnullableOptionalList.iterator()) { - put(AnonymousTag, item) - } - endArray() - } + val optnullableOptionalList = nullableOptionalList.get() + startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + for (item in optnullableOptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) } @@ -158,112 +158,151 @@ class UnitTestingClusterNullablesAndOptionalsStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNullablesAndOptionalsStruct { tlvReader.enterStructure(tlvTag) - val nullableInt = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_INT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) - null - } - val optionalInt = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_OPTIONAL_INT))) - } else { - Optional.empty() - } - val nullableOptionalInt = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) - null - } - val nullableString = if (!tlvReader.isNull()) { - tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) - null - } - val optionalString = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) - } else { - Optional.empty() - } - val nullableOptionalString = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) - null - } - val nullableStruct = if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) - null - } - val optionalStruct = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { - Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), tlvReader)) - } else { - Optional.empty() - } - val nullableOptionalStruct = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { - Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) - null - } - val nullableList = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) - null - } - val optionalList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val nullableOptionalList = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - null - } - + val nullableInt = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_INT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) + null + } + val optionalInt = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_OPTIONAL_INT))) + } else { + Optional.empty() + } + val nullableOptionalInt = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) + null + } + val nullableString = + if (!tlvReader.isNull()) { + tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) + null + } + val optionalString = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) + } else { + Optional.empty() + } + val nullableOptionalString = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) + null + } + val nullableStruct = + if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) + null + } + val optionalStruct = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { + Optional.of( + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_OPTIONAL_STRUCT), + tlvReader + ) + ) + } else { + Optional.empty() + } + val nullableOptionalStruct = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { + Optional.of( + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), + tlvReader + ) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) + null + } + val nullableList = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) + null + } + val optionalList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val nullableOptionalList = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + null + } + tlvReader.exitContainer() - return UnitTestingClusterNullablesAndOptionalsStruct(nullableInt, optionalInt, nullableOptionalInt, nullableString, optionalString, nullableOptionalString, nullableStruct, optionalStruct, nullableOptionalStruct, nullableList, optionalList, nullableOptionalList) + return UnitTestingClusterNullablesAndOptionalsStruct( + nullableInt, + optionalInt, + nullableOptionalInt, + nullableString, + optionalString, + nullableOptionalString, + nullableStruct, + optionalStruct, + nullableOptionalStruct, + nullableList, + optionalList, + nullableOptionalList + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt index 3b541c8d11d6b0..7266ca0054d7d8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -82,7 +80,7 @@ class UnitTestingClusterSimpleStruct( val f = tlvReader.getUByte(ContextSpecificTag(TAG_F)) val g = tlvReader.getFloat(ContextSpecificTag(TAG_G)) val h = tlvReader.getDouble(ContextSpecificTag(TAG_H)) - + tlvReader.exitContainer() return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt index 1f38827ddec220..4e4b00571da5d9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt @@ -53,7 +53,10 @@ class UnitTestingClusterTestFabricScoped( put(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U), fabricSensitiveInt8u) if (optionalFabricSensitiveInt8u.isPresent) { val optoptionalFabricSensitiveInt8u = optionalFabricSensitiveInt8u.get() - put(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), optoptionalFabricSensitiveInt8u) + put( + ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), + optoptionalFabricSensitiveInt8u + ) } if (nullableFabricSensitiveInt8u != null) { put(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U), nullableFabricSensitiveInt8u) @@ -62,9 +65,12 @@ class UnitTestingClusterTestFabricScoped( } if (nullableOptionalFabricSensitiveInt8u != null) { if (nullableOptionalFabricSensitiveInt8u.isPresent) { - val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), optnullableOptionalFabricSensitiveInt8u) - } + val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() + put( + ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), + optnullableOptionalFabricSensitiveInt8u + ) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) } @@ -93,41 +99,63 @@ class UnitTestingClusterTestFabricScoped( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScoped { tlvReader.enterStructure(tlvTag) val fabricSensitiveInt8u = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U)) - val optionalFabricSensitiveInt8u = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - val nullableFabricSensitiveInt8u = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - null - } - val nullableOptionalFabricSensitiveInt8u = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - null - } - val fabricSensitiveCharString = tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) - val fabricSensitiveStruct = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), tlvReader) - val fabricSensitiveInt8uList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val optionalFabricSensitiveInt8u = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) + } else { + Optional.empty() + } + val nullableFabricSensitiveInt8u = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + null + } + val nullableOptionalFabricSensitiveInt8u = + if (!tlvReader.isNull()) { + if ( + tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + ) { + Optional.of( + tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + null + } + val fabricSensitiveCharString = + tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) + val fabricSensitiveStruct = + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), + tlvReader + ) + val fabricSensitiveInt8uList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return UnitTestingClusterTestFabricScoped(fabricSensitiveInt8u, optionalFabricSensitiveInt8u, nullableFabricSensitiveInt8u, nullableOptionalFabricSensitiveInt8u, fabricSensitiveCharString, fabricSensitiveStruct, fabricSensitiveInt8uList, fabricIndex) + return UnitTestingClusterTestFabricScoped( + fabricSensitiveInt8u, + optionalFabricSensitiveInt8u, + nullableFabricSensitiveInt8u, + nullableOptionalFabricSensitiveInt8u, + fabricSensitiveCharString, + fabricSensitiveStruct, + fabricSensitiveInt8uList, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt index 5478f2bd44b175..9a7f7d3ba58b08 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestListStructOctet( - val member1: ULong, - val member2: ByteArray -) { +class UnitTestingClusterTestListStructOctet(val member1: ULong, val member2: ByteArray) { override fun toString(): String = buildString { append("UnitTestingClusterTestListStructOctet {\n") append("\tmember1 : $member1\n") @@ -52,7 +47,7 @@ class UnitTestingClusterTestListStructOctet( tlvReader.enterStructure(tlvTag) val member1 = tlvReader.getULong(ContextSpecificTag(TAG_MEMBER1)) val member2 = tlvReader.getByteArray(ContextSpecificTag(TAG_MEMBER2)) - + tlvReader.exitContainer() return UnitTestingClusterTestListStructOctet(member1, member2) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt index fd4efa9375bbe4..8840aec05a78bd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UserLabelClusterLabelStruct( - val label: String, - val value: String -) { +class UserLabelClusterLabelStruct(val label: String, val value: String) { override fun toString(): String = buildString { append("UserLabelClusterLabelStruct {\n") append("\tlabel : $label\n") @@ -52,7 +47,7 @@ class UserLabelClusterLabelStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return UserLabelClusterLabelStruct(label, value)